X

Jade Node.js Template Engine

Jade

Jade Node.js Template Engine is a templating language for node.js, it provides an alternative syntax to write your HTML, some may say more pythonic or haml style. Jade by default comes with express web application framework for node.js, it is designed primarily for server side templating in node.js, and last but not least it is a high performance template engine.

Lets take a look at a simple jade file compare it to your html file.
HTMLvs Jade



  
  
  
    

Hello world

This is a simple hello world example

doctype html
html
  head
  body
    h1 Hello world
    p.
      This is a simple hello world example   

As one can see the jade syntax is more terse and concise, but one has to remember those spaces/indentation are quite important for jade.

Installing Jade

Jade by default comes with express web application for node.js, but one can also install it by npm.

$ npm install jade

One can also compile and use jade with command line

$ echo "p hello world" > helloworld.jade

To generate the html file we can run the jade command

$ jade helloworld.jade
   rendered helloworld.html
$ cat helloworld.html

hello world

As we can see above it automatically create the angle tags for us for the paragraph tag.

In my next blog post I will be covering the basic syntax of jade

Taswar Bhatti:
Related Post