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 ?
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.
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.
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.
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.
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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With