In this blog we will see the comparison of different NodeJs templating engines as well as we will go through the basics of NodeJs then we will create a signup application in NodeJs with MongoDB as backend.
If you are starting with NodeJs from this blog post, you are right place, when i started NodeJs previous week and tried some examples i got into the confusion of Templating in NodeJs and given 2 days in it, so when you will start trying NodeJs you would be at the position of choosing the best templating engine for NodeJs, as there is a huge list of templating engines, confusion in choosing best is obvious. So lets start with some names of templating engines but please have a look on basics why we need them, because i am going to cover them here, it will make this post a book then.
So lets start with some amazing top priority names on the basis of their stars and community support:
In two days of comparisons and reading i found a web app that is allowing you to choose your requirements and on the basis of that you can find the best suitable engine, checkout- template engine chooser.
So lets get list some of them that i have tried and read about : I will share my liking later in this blog with reasons.
- – Jade
- – EJS
- – doT
- – swig
doT: there is no doubt in using doT as a template engine, it is not so easy to use first off all, BUT: fulfill all of these production questions:
- – If your app is using for client and server both:
- – If your template huge logic
- – If you need to make your app fastest.
- – If you need to pre-compile templates
and much more…
Jade: You must be familiar with Jade (HAML, checkout my previous post of HAML), Jade is like magic, less writing full relax, but in case of NodeJs I discussed with one of my friend she is Jade developer, she says it is good to code in Jade for me but when I pass the template to developer it has to be converted into html then again in jade, so a bit time consuming.
EJS: EJS is CanJS’s default template language, which provides live binding when used with Observes. EJS is very easy to use; you write the HTML you want to be in the template, along with a few magic tags where you want dynamic behavior. But EJS does not support block functionality.
Swig: Swig does not abstract HTML syntax from you (like e.g. Jade does) giving a certain filling of control over the markup. You can feel angularjs syntax here with swig and yes it supports block functionality as well.
I personally liked using EJS may be because I started learning NodeJs with it, but it depends on your understanding and requirements for the project, first thing comes in priority is performance and then ease of writing code. Although doT is doing awesome job with performance but it’s syntax will not make you comfortable if your are not a pure js loving guy.
Now about simple signup with NodeJs and MongoDB, that we are not covering in the very next blog because this was very important first to start with NodeJs, so your homework is to learn about basics of NodeJs & MongoDB, just the basics like why to use, where to use, i know title is confusing you but come back here to get a bootstart with NodeJs believe me it is very easy.
Leave your comments, views and suggestions.