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
|
|
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.
1 |
$ npm install jade |
One can also compile and use jade with command line
1 |
$ echo "p hello world" > helloworld.jade |
To generate the html file we can run the jade command
1 2 3 4 |
$ jade helloworld.jade rendered helloworld.html $ cat helloworld.html <p>hello world</p> |
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
Leave A Comment