Jade: a clean, whitespace-sensitive template language for writing HTML
February 20, 2015
An example template
Below an example of a Jade template, taken from the jade homepage. Notice that the notation of tags, classes and id’s much resembles CSS selectors. The template also includes one variable called youAreUsingJade, which we can use to control the rendering output.
Converting a template to HTML text involves two steps. The first step compiles the template with some formatting options into a closure. The binding for this is implemented in jade_compile.
The second step calls the closure with optionally some local variables to render the output to HTML.
The output looks like this:
Note how the HTML output changes when setting local variables:
That’s it. Hover over to the jade website to learn about the full power of this amazing templating language.