How to use pug - 10 common examples

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 DefinitelyTyped / DefinitelyTyped / pug / pug-tests.ts View on Github external
/// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
        let obj = pug.compileClientWithDependenciesTracked(source);
        clientFunctionString = obj.body;
        str = obj.body;
        let strArray: string[] = obj.dependencies;
    }

    {
        /// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
        clientFunctionString = pug.compileFileClient(path);
        str = pug.compileFileClient(path);
    }

    {
        /// pug.render(source, ?options, ?callback) https://pugjs.org/api/reference.html#pugrendersource-options-callback
        str = pug.render(source);

        // test type for callback paraments
        pug.render(source, {}, (err, html) => {
            let e: Error = err;
            str = html;
        });
    }

    {
        /// pug.renderFile(path, ?options, ?callback) https://pugjs.org/api/reference.html#pugrenderfilepath-options-callback
        str = pug.renderFile(path);

        // test type for callback paraments
        pug.renderFile(path, {}, (err, html) => {
            let e: Error = err;
            str = html;
github epinna / tplmap / tests / env_node_tests / connect-app.js View on Github external
app.use('/pug', function(req, res){
  if(req.url) {
    var url_parts = url.parse(req.url, true);

    var inj = url_parts.query.inj;
    var tpl = '';
    if('tpl' in url_parts.query && url_parts.query.tpl != '') {
      // Keep the formatting a-la-python
      tpl = url_parts.query.tpl.replace('%s', inj);
    }
    else {
      tpl = inj;
    }
    res.end(randomstring.generate() + pug.render(tpl) + randomstring.generate());
  }
});
github DefinitelyTyped / DefinitelyTyped / pug / pug-tests.ts View on Github external
/// pug.compileClient(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientsource-options
        clientFunctionString = pug.compileClient(path);
        str = pug.compileClient(path);
    }

    {
        /// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
        let obj = pug.compileClientWithDependenciesTracked(source);
        clientFunctionString = obj.body;
        str = obj.body;
        let strArray: string[] = obj.dependencies;
    }

    {
        /// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
        clientFunctionString = pug.compileFileClient(path);
        str = pug.compileFileClient(path);
    }

    {
        /// pug.render(source, ?options, ?callback) https://pugjs.org/api/reference.html#pugrendersource-options-callback
        str = pug.render(source);

        // test type for callback paraments
        pug.render(source, {}, (err, html) => {
            let e: Error = err;
            str = html;
        });
    }

    {
        /// pug.renderFile(path, ?options, ?callback) https://pugjs.org/api/reference.html#pugrenderfilepath-options-callback
github DefinitelyTyped / DefinitelyTyped / pug / pug-tests.ts View on Github external
clientFunctionString = pug.compileClient(path);
        str = pug.compileClient(path);
    }

    {
        /// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
        let obj = pug.compileClientWithDependenciesTracked(source);
        clientFunctionString = obj.body;
        str = obj.body;
        let strArray: string[] = obj.dependencies;
    }

    {
        /// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
        clientFunctionString = pug.compileFileClient(path);
        str = pug.compileFileClient(path);
    }

    {
        /// pug.render(source, ?options, ?callback) https://pugjs.org/api/reference.html#pugrendersource-options-callback
        str = pug.render(source);

        // test type for callback paraments
        pug.render(source, {}, (err, html) => {
            let e: Error = err;
            str = html;
        });
    }

    {
        /// pug.renderFile(path, ?options, ?callback) https://pugjs.org/api/reference.html#pugrenderfilepath-options-callback
        str = pug.renderFile(path);
github DefinitelyTyped / DefinitelyTyped / pug / pug-tests.ts View on Github external
{
        /// pug.compile(source, ?options) https://pugjs.org/api/reference.html#pugcompilesource-options
        compileTemplate = pug.compile(source);
        template = compileTemplate();
    }

    {
        /// pug.compileFile(path, ?options) https://pugjs.org/api/reference.html#pugcompilefilepath-options
        compileTemplate = pug.compileFile(path);
        template = compileTemplate();
    }

    {
        /// pug.compileClient(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientsource-options
        clientFunctionString = pug.compileClient(path);
        str = pug.compileClient(path);
    }

    {
        /// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
        let obj = pug.compileClientWithDependenciesTracked(source);
        clientFunctionString = obj.body;
        str = obj.body;
        let strArray: string[] = obj.dependencies;
    }

    {
        /// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
        clientFunctionString = pug.compileFileClient(path);
        str = pug.compileFileClient(path);
    }
github DefinitelyTyped / DefinitelyTyped / pug / pug-tests.ts View on Github external
{
        /// pug.compile(source, ?options) https://pugjs.org/api/reference.html#pugcompilesource-options
        compileTemplate = pug.compile(source);
        template = compileTemplate();
    }

    {
        /// pug.compileFile(path, ?options) https://pugjs.org/api/reference.html#pugcompilefilepath-options
        compileTemplate = pug.compileFile(path);
        template = compileTemplate();
    }

    {
        /// pug.compileClient(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientsource-options
        clientFunctionString = pug.compileClient(path);
        str = pug.compileClient(path);
    }

    {
        /// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
        let obj = pug.compileClientWithDependenciesTracked(source);
        clientFunctionString = obj.body;
        str = obj.body;
        let strArray: string[] = obj.dependencies;
    }

    {
        /// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
        clientFunctionString = pug.compileFileClient(path);
        str = pug.compileFileClient(path);
    }
github DefinitelyTyped / DefinitelyTyped / pug / pug-tests.ts View on Github external
{
        /// pug.compileFile(path, ?options) https://pugjs.org/api/reference.html#pugcompilefilepath-options
        compileTemplate = pug.compileFile(path);
        template = compileTemplate();
    }

    {
        /// pug.compileClient(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientsource-options
        clientFunctionString = pug.compileClient(path);
        str = pug.compileClient(path);
    }

    {
        /// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
        let obj = pug.compileClientWithDependenciesTracked(source);
        clientFunctionString = obj.body;
        str = obj.body;
        let strArray: string[] = obj.dependencies;
    }

    {
        /// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
        clientFunctionString = pug.compileFileClient(path);
        str = pug.compileFileClient(path);
    }

    {
        /// pug.render(source, ?options, ?callback) https://pugjs.org/api/reference.html#pugrendersource-options-callback
        str = pug.render(source);

        // test type for callback paraments
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 codingphasedotcom / Dypsy / lib / tasks / pug.js View on Github external
const destPath = path.join(distPath, fileData.dir);
		console.log(fileData.base);
		// create destination directory
		fse.mkdirsSync(destPath);

		// read page file
		const data = fse.readFileSync(`${srcPath}/${file}`, 'utf-8');

		// render page
		let pageContent;
		let completePage;

		// generate page content according to file type
		switch (fileData.ext) {
			case '.pug':
				var fn = pug.compile(data, {
					filename: `${srcPath}/${fileData.name}`,
					pretty: true
				})({
					pageTitle: 'Joes'
				});
				completePage = fn;
				break;
			default:
				pageContent = pageData.body;
		}
		// save the html file
		fse.writeFileSync(`${destPath}/${fileData.name}.html`, completePage);
	});
github framework7io / framework7-website / gulpfile.js View on Github external
var useCDN = true;
  var cdnPath = '//cdn.framework7.io';
  // var processVuePugFiles = require('./src/react-doc-generation/vue-pug-file-processing').processVuePugFiles;
  // var processReactHtmlFiles = require('./src/react-doc-generation/react-html-file-processing').processReactHtmlFiles;
  var pkg = require('./package.json');

  // Get src file url
  function getSrcFileUrl(file) {
    const srcFileUrl = `${pkg.repository.url}/edit/master/src/pug/${file.path.split('/src/pug/')[1]}`;
    return {
      srcFileUrl: srcFileUrl,
    };
  }

  // Pug Filter
  pug.filters['code'] = function (text) {
    return text
    .replace( //g, '>'   )
  }
  // Pug YAML Data
  function getYamlData(ymlPath) {
    var doc = yaml.safeLoad(fs.readFileSync(`./src/pug/${ymlPath}`, 'utf8'));
    return doc;
  }

  /* ==================================================================
  Check CDN
  ================================================================== */
  function checkIsLocal(local) {
    if (local) local = local.toString().replace('-', '');
    if (local === 'local') {