I'm looking at backbone.js and noticed that it supports various templating systems (they specifically refer to Mustache.js, Haml-js, and Eco, but I understand it can support even more)(like Pure and dust.js)

Why are there so many of these? What makes one better or different to the others? Can anyone shed light on what their individual strengths and weaknesses are?

  • 2
    Matter of preference, syntax and ease of use, functionalities provided (e.g. embedded JS execution or not etc.). It'll be very difficult to give a complete breakdown of all, but these are the dimensions of comparison IMHO
    – PhD
    Commented Aug 23, 2012 at 17:16

3 Answers 3


Here's a link to a LinkedIN Article where they detail their comparison and present their results as well as why did they select what they did (dust.js). This should give you some fair idea about the comparisons and what people are most likely to look for in templating solutions on client side and what are their strengths/weaknesses in those areas.


PhD already answered really well the comparison points, so I am gonna focus on

Why are there so many of these?

Quite a few reasons :

  • They have different philosophy concerning what should be in a template. Some try to force the "no logic in a template" rule, other don't care : For example, mustache is very strict, underscore let you use any sort of javascript in the template.
  • They were made by different people who had different need. Some wanted a very generic template system implementable in any language, other only needed javascript and optimised for that.
  • Some only needed the template to generate HTML, and optimized the syntax for that. Other made them capable of outputting any text content, but with a syntax that could be considered less confortable.

It all boil down to the definition of design: "Design is the art of balancing conflicting requirements". People who designed the various template engine had different priorities, so they produced different designs.

  • 3
    Don't forget to include a healthy dose of NIH. Template systems are relatively easy to write so many people think they can write their own & make it better. Commented Mar 14, 2014 at 0:21
  • Oh, so true :) . Commented Mar 14, 2014 at 15:36

I'm currently going for Mustache.

The main reason, is that it's available in Ruby, JavaScript, Python, Erlang, node.js, PHP, Perl, Objective-C, Java, .NET, Android, C++, Go, Lua, ooc, ActionScript, ColdFusion, Scala, Clojure, Fantom, CoffeeScript, D, Haskell, XQuery, ASP, Io, Dart, and Haxe.

This means you can share your templates between your JS and whatever backend language you're using, which is very useful if you want to render your layout in backend and rerender it in frontend when updating. While some other template systems also have implementations in other languages than their initial implementation, Mustache is the only one with multiple official implementations.

Mustache templates also have a very simple syntax that don't add much clutter to your HTML and actually still look like HTML (unlike HAML).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.