How to use the pug.renderFile function in pug

To help you get started, we’ve selected a few pug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github knockout / tko / tko.io / make.js View on Github external
function makeHtml({htmlSettings, scripts, links, styles}, config) {
  /**
   * Make build/index.html
   */
  console.log(`  Making ${htmlSettings.dest}`)
  Object.assign(htmlSettings, {scripts, links, styles}) // add links + scripts
  const sections = Array.from(genSections(htmlSettings, config))
  const locals = Object.assign(htmlSettings, {sections})
  const html = pug.renderFile('src/index.pug', locals)
  fs.writeFileSync(htmlSettings.dest, html)
}
github cginternals / webgl-operate / pugconfig.js View on Github external
function render(template, target, object, outputDir = '') {
    const src = path.join(websiteDir, template + '.pug');
    const dst = path.join(buildDir, outputDir, target + '.html');
    if (!fs.existsSync(src)) {
        console.log('skipped:', target);
        return;
    }

    const html = pug.renderFile(src, object);
    fs.writeFileSync(dst, html);
    console.log('emitted:', dst);
}
github SynBioHub / synbiohub / lib / views / attachment.js View on Github external
locals.collectionIcon = collectionIcon

        locals.submissionCitations = submissionCitations

        locals.meta.description = locals.meta.description.split(';').join('<br>')

        locals.attachmentType = attachment.getAnnotation('http://wiki.synbiohub.org/wiki/Terms/synbiohub#attachmentType')
        locals.attachmentHash = attachment.getAnnotation('http://wiki.synbiohub.org/wiki/Terms/synbiohub#attachmentHash')
        locals.attachmentDownloadURL = url + '/download'
        locals.size = attachment.getAnnotation('http://wiki.synbiohub.org/wiki/Terms/synbiohub#attachmentSize')

        locals.attachmentIsImage = locals.attachmentType === 'http://wiki.synbiohub.org/wiki/Terms/synbiohub#imageAttachment'

        locals.annotations = filterAnnotations(req, attachment.annotations);

        res.send(pug.renderFile('templates/views/attachment.jade', locals))

    }).catch((err) =&gt; {
github SynBioHub / synbiohub / lib / views / submit.js View on Github external
}).catch((err) => {
      if (req.forceNoHTML || !req.accepts('text/html')) {
        res.status(500).type('text/plain').send(err.stack)
      } else {
        const locals = {
          config: config.get(),
          section: 'errors',
          user: req.user,
          errors: [err.stack]
        }
        res.send(pug.renderFile('templates/views/errors/errors.jade', locals))
      }
    })
  })
github SynBioHub / synbiohub / lib / views / setup.js View on Github external
function setupForm (req, res, settings, locals) {
  locals = extend({
    config: config.get(),
    title: 'First Time Setup - SynBioHub',
    settings: settings,
    errors: []
  }, locals)

  res.send(pug.renderFile('templates/views/setup.jade', locals))
}
github SynBioHub / synbiohub / lib / api / sbolnr.js View on Github external
}).catch((err) => {
    if (!req.accepts('text/html')) {
      return res.status(404).send(uri + ' not found')
    } else {
      var locals = {
        config: config.get(),
        section: 'errors',
        user: req.user,
        errors: [ err.stack ]
      }
      res.send(pug.renderFile('templates/views/errors/errors.jade', locals))
    }
  })
}
github SynBioHub / synbiohub / lib / views / advancedSearch.js View on Github external
locals = extend({
      collectionMeta: collectionMeta,
      objectTypes: [{ name: 'Collection' }, { name: 'ComponentDefinition' }, { name: 'Model' }, { name: 'ModuleDefinition' }, { name: 'Sequence' }],
      creators: lists.creatorList,
      partStatuses: lists.partStatusList,
      sampleStatuses: lists.sampleStatusList,
      statuses: lists.statusList,
      experiences: lists.experienceList,
      types: lists.typeList,
      roles: lists.roleList,
      igemRoles: lists.igemRoleList,
      collections: lists.collectionList
    }, locals)

    if (req.originalUrl.endsWith('/createCollection')) {
      res.send(pug.renderFile('templates/views/createCollection.jade', locals))
    } else {
      res.send(pug.renderFile('templates/views/advanced-search.jade', locals))
    }
  }).catch((err) => {
    locals = {
github mrsum / webpack-svgstore-plugin / src / helpers / utils.js View on Github external
const _createSprite = function(data, template) {
  return pug.renderFile(template, data);
};
github SynBioHub / synbiohub / lib / views / admin / jobs.js View on Github external
}).then((jobs) => {
    var locals = {
      config: config.get(),
      section: 'admin',
      adminSection: 'jobs',
      user: req.user,
      jobs: jobs
    }

    res.send(pug.renderFile('templates/views/admin/jobs.jade', locals))
  }).catch((err) => {
    res.status(500).send(err.stack)
github SynBioHub / synbiohub / lib / actions / createBenchlingSequence.js View on Github external
user: req.user,
          benchlingRemotes: benchlingRemotes,
          submission: {}
        }
        res.send(pug.renderFile('templates/views/selectBenchlingRemote.jade', locals))
        return
      }

      if (benchlingRemotes.length === 0) {
        const locals = {
          config: config.get(),
          section: 'errors',
          user: req.user,
          errors: [ 'No Benchling remote instances configured' ]
        }
        res.send(pug.renderFile('templates/views/errors/errors.jade', locals))
        return
      }

      if (benchlingRemotes.length === 1) {
        benchlingRemote = benchlingRemotes[0].id
      }
    } else {
      benchlingRemote = req.body.benchlingRemote
    }
  }

  const { graphUri, uri, designId, share } = getUrisFromReq(req, res)

  fetchSBOLObjectRecursive(uri, graphUri).then((result) => {
    const sbol = result.sbol
    const componentDefinition = result.object