How to use the pug.compileClient 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 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 Aratramba / pug-doc / lib / parser.js View on Github external
lines.forEach(function(line) {
        if (line.trim() === EXAMPLE_BLOCK) {
          var indent = detectIndent(line).indent.length;
          line = rebaseIndent(src.split("\n"), indent).join("\n");
        }
        newSrc.push(line);
      });
    }
  });

  newSrc = newSrc.join("\n");

  locals = Object.assign({}, locals, meta.locals);

  // compile pug
  var compiled = pug.compileClient(newSrc, { filename: filename });

  // render pug function and catch error
  try {
    return Function(
      "pug",
      compiled + "\n" + "return template(" + JSON.stringify(locals || {}) + ");"
    )(pugRuntime);
  } catch (err) {
    // render again to get better error messages
    try {
      compiled = pug.compileClient(newSrc, {
        filename: filename,
        compileDebug: true
      });
      Function(
        "pug",
github Aratramba / pug-doc / lib / parser.js View on Github external
locals = Object.assign({}, locals, meta.locals);

  // compile pug
  var compiled = pug.compileClient(newSrc, { filename: filename });

  // render pug function and catch error
  try {
    return Function(
      "pug",
      compiled + "\n" + "return template(" + JSON.stringify(locals || {}) + ");"
    )(pugRuntime);
  } catch (err) {
    // render again to get better error messages
    try {
      compiled = pug.compileClient(newSrc, {
        filename: filename,
        compileDebug: true
      });
      Function(
        "pug",
        compiled +
          "\n" +
          "return template(" +
          JSON.stringify(locals || {}) +
          ");"
      )(pugRuntime);
    } catch (debugErr) {
      process.stderr.write(debugErr.toString());
      return "";
    }
  }
github pugjs / pug-cli / index.js View on Github external
process.stdin.on('end', function(){
    var output;
    if (options.client) {
      output = pug.compileClient(buf, options);
    } else {
      var fn = pug.compile(buf, options);
      var output = fn(options);
    }
    process.stdout.write(output);
  }).resume();
}
github nodeca / nodeca.core / lib / bundler / plugins / pug.js View on Github external
return Promise.resolve().then(() => {
    const pug = require('pug');

    let tpl = pug.compileClient(context.asset.source, {
      compileDebug:           false,
      doctype:                'html',
      filename:               context.asset.logicalPath,
      inlineRuntimeFunctions: false,
      plugins:                [ npmResolverPlugin() ],
      self:                   true
    }).toString();

    context.asset.source = tpl;
  });
};