Jump to...

Pug

Installation

Pug Syntax

Classes, IDs and Attributes

Plain Text and Text Blocks

Comments

Rendering Proccess of Pug

pug.compile(source, options)

pug.render(source, options, callback)

Options

Option Accepts Action
filename string The name of the file being compiled. Used in exceptions, and required for relative include \s and extend\s. Defaults to Pug.
basedir string The root directory of all absolute inclusion.
doctype string If the doctype is not specified as part of the template, you can specify it here. It is sometimes useful to get self-closing tags and remove mirroring of boolean attributes.
filters object Hash table of custom filters. Defaults to undefined.
self boolean Use a self namespace to hold the locals. It will speed up the compilation, but instead of writing variable you will have to write self.variable to access a property of the locals object. Defaults to false.
debug boolean If set to true, the tokens and function body are logged to stdout.
compileDebug boolean If set to true, the function source will be included in the compiled template for better error messages (sometimes useful in development). It is enabled by default, unless used with Express in production mode.
globals Array<string> Add a list of global names to make accessible in templates.
cache boolean If set to true, compiled functions are cached. filename must be set as the cache key. Only applies to render functions. Defaults to false.
inlineRuntimeFunctions boolean Inline runtime functions instead of require-ing them from a shared version. For compileClient functions, the default is true (so that one does not have to include the runtime). For all other compilation or rendering types, the default is false.
name string The name of the template function. Only applies to compileClient functions. Defaults to 'template'.

Template Inheritance

Buffered vs Unbuffered Code

Interpolation

Iteration



   - [Jump to...](#jump-to)