DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. JavaScript
  4. A Look at my Favorite Node.js Templating Engines

A Look at my Favorite Node.js Templating Engines

If you're a beginner looking for a place to start, or an experienced developer looking for a new tool, read on for a review of a few Node.js templating engines.

Nikhil Kumar user avatar by
Nikhil Kumar
·
Feb. 26, 17 · Opinion
Like (0)
Save
Tweet
Share
14.04K Views

Join the DZone community and get the full member experience.

Join For Free

In this blog, we will look at a comparison of different Node.js templating engines and go through the basics of Node.js. Then we will create a signup application in Node.js with MongoDB as the backend.

If you are starting with Node.js from this blog post, you are at the right place. When I started working with Node.js, I got confused will all of the templating in Node.js. So when you start trying Node.js our for yourself, you'll be in the position of choosing the best templating engine. And there is a huge list of templating engines, so don't feel bad if you get confused. So let's start with some names of templating engines, but please have a look at the basics of why we need them because I am not going to cover them here, so as not to turn this post into a book.

So let's start with some amazing top priority names on the basis of their stars and community support:

1. Mustache
2. Handlebars
3. doT
4. Dust
5. EJS
6. Underscore
7. Jade

So let's list some of the ones that I have tried and read about:

  1. Jade
  2. EJS
  3. doT
  4. swig

doT:

doT isn't necessarily the easiest to use, but if it fulfills the following requirements, it might be right for you: 

  1. If your app is used by both client and server side.
  2. If your template requires huge logic If you need to make your app faster.
  3. If you need to pre-compile templates.

and much more…

Jade:

You should definitely be familiar with Jade, Jade is like magic. It means less writing and more relaxing. In the case of Node.js, it can be a bit time-consuming, as you have to convert the file into HTML then back into Jade.

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 in the template, along with a few magic tags where you want dynamic behavior. But EJS does not support block functionality.

Your javascript should be good for EJS though.

Swig:

Swig does not abstract HTML syntax from you (like Jade does) giving a certain feeling of control over the markup. You can fill angular.js syntax here with swig, and, yes, it supports block functionality as well.

Conclusion:

I personally liked using EJS, maybe because I started learning NodeJs with it, but it depends on your understanding and requirements for the project. The first priority is performance and then ease of writing code. Although doT is doing an awesome job with performance, its syntax will not make you comfortable if you are not a pure js loving guy.

Node.js Engine

Published at DZone with permission of Nikhil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top 5 Node.js REST API Frameworks
  • Best Practices for Writing Clean and Maintainable Code
  • How To Validate Three Common Document Types in Python
  • Distributed Stateful Edge Platforms

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: