JavaScript in Jade

Jade templates can use JavaScript to calculate values and control rendering.

There are three useful forms of template code: code that performs logic without producing output, code that produces escaped output, and code that produces unescaped output.

Unbuffered code

Use - when you need to execute JavaScript without directly writing the result to the HTML.

- var title = "Welcome"

h1= title

Buffered code

Use = when you want the result of an expression rendered into the document.Jade also supports block unbuffered code:

p= username

The rendered value is escaped.

Unescaped output

Use != when you intentionally need the result inserted without HTML escaping.

div!= trustedHtml

Use this carefully. Never insert untrusted user input as unescaped HTML. It can create cross-site scripting vulnerabilities. (source)

Jade Language © 2026 | About Us | Privacy Policy