Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
/// 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);
}
{
/// 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);
}
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",
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 "";
}
}
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();
}
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;
});
};