Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js - what are the advantages of using jade

Tags:

node.js

pug

I learnt that JADE is a template language and it is preferred engine for express.

What are the advantages of using JADE instead of html ? Is it possible to use html directly instead of using jade ?

like image 873
Vinoth Avatar asked Jul 05 '12 12:07

Vinoth


People also ask

What is jade used for node JS?

Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.

Is Jade better than EJS?

They are different, that's for sure, but "better" is quite relative term. I prefer EJS because I think HTML is not too bad, plus it allows me to work with others without them having to learn Jade. However, Jade is rather clean and makes for some neat code in your views. Pick whatever you feel more comfortable.

Is EJS good to use?

It is a simple templating language/engine that lets its user generate HTML with plain javascript. EJS is mostly useful whenever you have to output HTML with a lot of javascript.

Which is better EJS or pug?

According to the StackShare community, Pug has a broader approval, being mentioned in 230 company stacks & 608 developers stacks; compared to EJS, which is listed in 9 company stacks and 13 developer stacks.


1 Answers

Jade has a cleaner, more readable syntax and comes with filters and helpers: https://github.com/visionmedia/jade#a7

If you're going to migrate HTML files to jade, this converter might come handy: http://html2jade.aaron-powell.com/

...but you can also use HTML.

app.set('view engine', 'html'); 

http://expressjs.com/guide.html#view-rendering

I'm using EJS ( http://code.google.com/p/embeddedjavascript/) as the rendering engine in my express app, but keep a .html suffix on the template files like this:

app.set('view engine', 'html'); app.register('.html', require('ejs')); 

(requires ejs be installed, which you can easily do via npm install ejs)

like image 90
mgherkins Avatar answered Oct 03 '22 20:10

mgherkins