StrongLoop | Comparing JavaScript Templating Engines: Jade, Mustache, Dust and More
Lets talk templates, specifically JavaScript powered templates. Even more specifically – template engines that work as well on the server side as they do on the client side. After all, this is the great promise and advantage that isomorphic JavaScript brings to the table – ability to run the same code everywhere.
The big benefit of such approach when it comes to templates specifically is being able to render HTML on the server side, send it over the wire to a client and then have that client interact with the page and have it change using the same template bits and maybe even some shared logic. That can be a huge gain in terms of effort and reduces footprint of your application.
In this article I want to look at some of the most popular JavaScript templating engines. It's not my intent to compare them or do some silly benchmarking. I don't think subjectively evaluating a bunch of templating engines and picking the one I like best is helpful in any way. Most of the engines bring something unique to the table and my idea of DRY might not necessarily match yours.
Having said that, the template engines in this articles were selected based on a simple "GitHub score". How was that determined you might ask? I've come up with a simple formula:
Finally, the last criteria for selection is project activity in general. I decided not to work that into the formula to keep things simple. There are a few engines that were excluded based on the lack of any activity over an extensive amount of time such as Eco and Haml.js. These could be considered abandoned in my opinion. EJS and Mustache.js get a break here because they are fairly simple and there aren't any new features in general.
With that in mind, I'm going to give a brief sample of what markup looks like for each engine, the minimum code necessary to render that markup to HTML followed by some pros and cons.
Please note, everything in this article represents my personal opinion and might not match yours. The purpose here is to show you different templating languages, give you my personal take on each and let your decide for yourself.
Read full article from StrongLoop | Comparing JavaScript Templating Engines: Jade, Mustache, Dust and More
No comments:
Post a Comment