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)

My question is really 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.

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
–
PhDAug 23 '12 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.

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).