package
Default code-generator for pug. It generates HTML via a JavaScript template function.
npm install pug-code-genGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Latest published Mar 13, 2026
latest
canary
Default code-generator for pug. It generates HTML via a JavaScript template function.
npm install pug-code-genvar generateCode = require('pug-code-gen');generateCode(ast, options)Generate a JavaScript function string for the given AST.
ast is a fully expanded AST for Pug, with all inclusion, extends, and filters resolved.
options may contain the following properties that have the same meaning as the options with the same names in pug:
falsetrueundefinedfalse[]falseIn addition to above, pug-code-gen has the following unique options:
compileDebug is true; default is undefined'template'var lex = require('pug-lexer');
var parse = require('pug-parser');
var wrap = require('pug-runtime/wrap');
var generateCode = require('pug-code-gen');
var funcStr = generateCode(parse(lex('p Hello world!')), {
compileDebug: false,
pretty: true,
inlineRuntimeFunctions: false,
templateName: 'helloWorld'
});
//=> 'function helloWorld(locals) { ... }'
var func = wrap
new generateCode.CodeGenerator(ast, options)The constructor for the internal class of the code generator. You shouldn't need to use this for most purposes.
MIT
pug-bot
pug-bot@rollingversions.com
Estimated unpacked size across 15 packages.
2.1 MB
Includes dependencies.
8 direct dependencies.
^7.0.0
7.0.2
^1.1.0
1.1.0
^3.0.0
3.0.0
^2.1.0
2.1.0
^3.0.1
3.0.1