API Documentation
This page details how to render jade using the JavaScript API in node.js
Installation
via npm:
npm install jade
Usage
options
All API methods take the following set of options:
- filename:
- string
- Used in exceptions, and required for relative includes and extends
- 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.
- pretty:
- boolean | string
- Adds whitespace to the resulting html to make it easier for a human to read using
' '
as indentation. If a string is specified, that will be used as indentation instead (e.g.'\t'
). - self:
- boolean
- Use a
self
namespace to hold the locals (false by default) - debug:
- boolean
- If set to true, the tokens and function body is 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.
- cache:
- boolean
- If set to true, compiled functions are cached.
filename
must be set as the cache key. - compiler:
- class
- Override the default compiler
- parser:
- class
- Override the default parser
- globals:
- Array.<string>
- Add a list of global names to make accessible in templates
jade.compile(source, options)
Compile some jade source to a function which can be rendered multiple times with different locals.
- source
- string
- The source jade to compile
- options
- options
- An options object (see above)
- returns
- function
- A function to generate the html from an object containing locals
var jade = require('jade');
+Jade - Template Engine API Documentation
This page details how to render jade using the JavaScript API in node.js
Installation
via npm:
npm install jade
Usage
options
All API methods take the following set of options:
{- filename:
- string
- Used in exceptions, and required for relative includes and extends
- 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.
- pretty:
- boolean | string
- Adds whitespace to the resulting html to make it easier for a human to read using
' '
as indentation. If a string is specified, that will be used as indentation instead (e.g. '\t'
). - self:
- boolean
- Use a
self
namespace to hold the locals (false by default) - debug:
- boolean
- If set to true, the tokens and function body is 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.
- cache:
- boolean
- If set to true, compiled functions are cached.
filename
must be set as the cache key. - compiler:
- class
- Override the default compiler
- parser:
- class
- Override the default parser
- globals:
- Array.<string>
- Add a list of global names to make accessible in templates
}jade.compile(source, options)
Compile some jade source to a function which can be rendered multiple times with different locals.
- source
- string
- The source jade to compile
- options
- options
- An options object (see above)
- returns
- function
- A function to generate the html from an object containing locals
var jade = require('jade');
// Compile a function
var fn = jade.compile('string of jade', options);
diff --git a/1.11.0/command-line/index.html b/1.11.0/command-line/index.html
index de0e67f09..ddf8709d0 100644
--- a/1.11.0/command-line/index.html
+++ b/1.11.0/command-line/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Command Line
+Jade - Template Engine Command Line
Installation
via npm:
$ npm install jade --global
diff --git a/1.11.0/index.html b/1.11.0/index.html
index 6563d24a9..301c83920 100644
--- a/1.11.0/index.html
+++ b/1.11.0/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Jade - Template Engine html(lang="en")
head
title= pageTitle
diff --git a/1.11.0/reference/attributes/index.html b/1.11.0/reference/attributes/index.html
index c64a6888d..0f4c09a19 100644
--- a/1.11.0/reference/attributes/index.html
+++ b/1.11.0/reference/attributes/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Attributes
Tag attributes look similar to html, however their values are just regular JavaScript.
a(href='google.com') Google
+Jade - Template Engine Attributes
Tag attributes look similar to html, however their values are just regular JavaScript.
a(href='google.com') Google
a(class='button', href='google.com') Google
<a href="google.com">Google</a><a class="button" href="google.com">Google</a>
All the normal JavaScript expressions work fine too:
- var authenticated = true
body(class=authenticated ? 'authed' : 'anon')
<body class="authed"></body>
diff --git a/1.11.0/reference/case/index.html b/1.11.0/reference/case/index.html
index 27cbc17e1..e1060e97f 100644
--- a/1.11.0/reference/case/index.html
+++ b/1.11.0/reference/case/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Case
The case statement is a shorthand for JavaScript's switch
statement and takes the following form:
- var friends = 10
+Jade - Template Engine Case
The case statement is a shorthand for JavaScript's switch
statement and takes the following form:
- var friends = 10
case friends
when 0
p you have no friends
diff --git a/1.11.0/reference/code/index.html b/1.11.0/reference/code/index.html
index 074237108..16369fa0e 100644
--- a/1.11.0/reference/code/index.html
+++ b/1.11.0/reference/code/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Code
Jade makes it possible to write inline JavaScript code in your templates. There are three types of code.
Unbuffered Code
Unbuffered code starts with -
does not add any output directly, e.g.
- for (var x = 0; x < 3; x++)
+Jade - Template Engine Code
Jade makes it possible to write inline JavaScript code in your templates. There are three types of code.
Unbuffered Code
Unbuffered code starts with -
does not add any output directly, e.g.
- for (var x = 0; x < 3; x++)
li item
<li>item</li>
<li>item</li>
<li>item</li>
diff --git a/1.11.0/reference/comments/index.html b/1.11.0/reference/comments/index.html
index d1ea755d8..7e2ae8124 100644
--- a/1.11.0/reference/comments/index.html
+++ b/1.11.0/reference/comments/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Comments
Single line comments look the same as JavaScript comments and must be placed on their own line:
// just some paragraphs
+Jade - Template Engine Comments
Single line comments look the same as JavaScript comments and must be placed on their own line:
// just some paragraphs
p foo
p bar
<!-- just some paragraphs -->
<p>foo</p>
diff --git a/1.11.0/reference/conditionals/index.html b/1.11.0/reference/conditionals/index.html
index 1addfde97..7498bf814 100644
--- a/1.11.0/reference/conditionals/index.html
+++ b/1.11.0/reference/conditionals/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Conditionals
Jade's first-class conditional syntax allows for optional parenthesis, and you may now omit the leading -
otherwise it's identical, still just regular javascript:
- var user = { description: 'foo bar baz' }
+Jade - Template Engine Conditionals
Jade's first-class conditional syntax allows for optional parenthesis, and you may now omit the leading -
otherwise it's identical, still just regular javascript:
- var user = { description: 'foo bar baz' }
- var authorised = false
#user
if user.description
diff --git a/1.11.0/reference/doctype/index.html b/1.11.0/reference/doctype/index.html
index b7936020a..657f15050 100644
--- a/1.11.0/reference/doctype/index.html
+++ b/1.11.0/reference/doctype/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Doctype
Jade - Template Engine Doctype
Doctype Shortcuts
There are shortcuts for commonly used doctypes:
- doctype html
<!DOCTYPE html>
- doctype xml
<?xml version="1.0" encoding="utf-8" ?>
- doctype transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- doctype strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- doctype frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
- doctype 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- doctype basic
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
- doctype mobile
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
Custom Doctypes
You can also use your own literal custom doctype:
Doctype Option
The doctype affects compilation in some other cases, for example self closing tags
and boolean attributes).
diff --git a/1.11.0/reference/extends/index.html b/1.11.0/reference/extends/index.html
index 1e0ca35cc..d2da950fb 100644
--- a/1.11.0/reference/extends/index.html
+++ b/1.11.0/reference/extends/index.html
@@ -1,4 +1,4 @@
-
Jade - Template Engine Extends - Template Inheritance
The extends
keyword allows a template to extend a layout or parent template.
+
Jade - Template Engine Extends - Template Inheritance
The extends
keyword allows a template to extend a layout or parent template.
It can then override certain pre-defined blocks of content.
//- layout.jade
diff --git a/1.11.0/reference/filters/index.html b/1.11.0/reference/filters/index.html
index 6ae4187aa..1fbff34c1 100644
--- a/1.11.0/reference/filters/index.html
+++ b/1.11.0/reference/filters/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Filters
Filters let you use other languages within a jade template.
+
Jade - Template Engine Filters
Filters let you use other languages within a jade template.
They take a block of plain text as an input.
All JSTransformers can be used as jade filters.
Popular filters include :coffee-script
, :babel
, :uglify-js
, :less
, and :markdown-it
.
:markdown
diff --git a/1.11.0/reference/includes/index.html b/1.11.0/reference/includes/index.html
index 3e88a7b33..36390ac50 100644
--- a/1.11.0/reference/includes/index.html
+++ b/1.11.0/reference/includes/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Includes
Includes allow you to insert the contents of one jade file into another.
//- index.jade
+Jade - Template Engine Includes
Includes allow you to insert the contents of one jade file into another.
//- index.jade
html
include ./includes/head.jade
diff --git a/1.11.0/reference/index.html b/1.11.0/reference/index.html
index 3fcedd0ab..5dc6e9527 100644
--- a/1.11.0/reference/index.html
+++ b/1.11.0/reference/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Language Reference
Jade is a terse language for writing HTML templates.
- Produces HTML
- Supports dynamic code
- Supports reusability (DRY)
To read about the features of the language, select them from
+
Jade - Template Engine
\ No newline at end of file
+})();
diff --git a/command-line/index.html b/command-line/index.html
index ca40e76f8..5af4711f8 100644
--- a/command-line/index.html
+++ b/command-line/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Command Line
+Jade - Template Engine Command Line
Installation
via npm:
$ npm install jade --global
@@ -39,4 +39,4 @@ Installation
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-})();
\ No newline at end of file
+})();
diff --git a/index.html b/index.html
index 083b3f0e7..5f486f19b 100644
--- a/index.html
+++ b/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Jade - Template Engine html(lang="en")
head
title= pageTitle
@@ -45,4 +45,4 @@
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-})();
\ No newline at end of file
+})();
diff --git a/reference/attributes/index.html b/reference/attributes/index.html
index 2cbb9f2cb..29992c67a 100644
--- a/reference/attributes/index.html
+++ b/reference/attributes/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Attributes
Tag attributes look similar to html, however their values are just regular JavaScript.
a(href='google.com') Google
+Jade - Template Engine Attributes
Tag attributes look similar to html, however their values are just regular JavaScript.
a(href='google.com') Google
a(class='button', href='google.com') Google
<a href="google.com">Google</a><a class="button" href="google.com">Google</a>
All the normal JavaScript expressions work fine too:
- var authenticated = true
body(class=authenticated ? 'authed' : 'anon')
<body class="authed"></body>
diff --git a/reference/case/index.html b/reference/case/index.html
index 951d01d13..8431cd80d 100644
--- a/reference/case/index.html
+++ b/reference/case/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine Case
The case statement is a shorthand for JavaScript's switch
statement and takes the following form:
- var friends = 10
+Jade - Template Engine Case
The case statement is a shorthand for JavaScript's switch
statement and takes the following form:
- var friends = 10
case friends
when 0
p you have no friends
diff --git a/reference/code/index.html b/reference/code/index.html
index adf56cc46..e70856be9 100644
--- a/reference/code/index.html
+++ b/reference/code/index.html
@@ -1,4 +1,4 @@
-Jade - Template Engine
+
+
+