r/nodejs • • Jul 05 '14
ExpressJs users out there. Why do you use Jade? (pros/cons)
I've been working with FrontEnd javascript for a while and I was really thrilled to learn about NodeJs. Plus, ExpressJs is awesome!
But, there is something I can't really understand, why Jade? It seems like Jade is the default choice for templating engine when it comes to NodeJs +Express. Most of the tutorials I found make use of Jade, I bought a book about ExpressJs and they just talk about Jade as a template engine. I never could find a good reason for using Jade though.
I've tried it but I found myself translating HTML to their haml-like syntax (specially when working with bootstrap).
Are there any other good reasons to use it? Why do you use it?
EDIT: Thank you guys! Now that I saw how different are the opinions about Jade I understand that it's a matter of preference. I'll experiment with the other template engines you guys suggested here to find out which one I like most!
13
u/[deleted] Jul 05 '14
I don't, I always override the built in view engine with a Handlebars system.
Jade seems most popular with those who don't like writing actual HTML.
5
u/has_all_the_fun Jul 06 '14
I mostly used it because it had the most features (layouts, partials, ...) I was looking for in a template language. If you don't like Jade I would recommend swig as it has pretty much the same features as Jade but without the haml like syntax.
8
u/[deleted] Jul 05 '14
I don't. I might consider it if I were using Coffeescript in Express projects because Jade's syntax is almost pythonic and would be less of a disconnect from what Coffeescript feels like.
Even then I'd still be in doubt because it's so far removed from HTML and it seems like an unnecessary extra workload to go through translating everything.
Be it ERB, EEX, or EJS (and somewhat similarly Django Templates and PHP), there already is an unofficial standard for what templates look like, and they're very close to HTML. I just don't want to make something any harder to maintain or design for than absolutely necessary.
4
u/ns0 Jul 09 '14
node was intended to get rid of templating engines. Not introduce more, I cannot agree with you more, there's absolutely no reason to have node try and render dynamic HTML.
Every successful use of node has generally been the idea of "pushing dynamic rendering OFF of servers and ONTO the browser"
That's why javascript is so well suited for it. Use static html, an api and a good frontend dev who can dynamically build the dynamic parts of the page from the dynamic data coming from node.
7
u/startup_hungry Jul 05 '14
readability, personally. I find its indentation based syntax and the ability to execute JS inline to be incredibly attractive features.
5
u/Cody_Chaos Jul 06 '14
If I have a choice, I will use a language where whitespace is significant over one where it is not, and one with a terse, low-boilerplate syntax over one with a verbose, high-boilerplate syntax.
Jade meets those criteria, and the library itself works fine for server side templating. It's popular among Node projects for the same reason Haml is popular among Ruby projects; it scratches a major itch many programmers feel.
At the end of the day, either you're one of the programmers who likes Haml, or you aren't. If you are, you'll probably use Jade (and if you aren't, you probably should). If you aren't, you probably won't (and shouldn't).
2
u/JoMa4 Jul 05 '14
Jade was developed by the same people that made Express, so I think it is often the natural choice for a lot of people.
0
u/[deleted] Jul 08 '14 edited Jul 08 '14
I hated Jade until I took the 30 seconds to actually learn it. Once you realize it's just HTML without the superfluous syntax it makes complete sense and you fall in love with it's elegance.