admin管理员组

文章数量:1221766

i'm very new to Handlebar js. In every article about the HandleBar js there is a word called (mustache js). So,
1. What is the relation between Handllebar js and Mustache js?
2. Is it necessary to read mustache js before handlebar js?
3. What s advantage of HandleBar js over Mustache js?

Thanks.

i'm very new to Handlebar js. In every article about the HandleBar js there is a word called (mustache js). So,
1. What is the relation between Handllebar js and Mustache js?
2. Is it necessary to read mustache js before handlebar js?
3. What s advantage of HandleBar js over Mustache js?

Thanks.

Share Improve this question edited May 22, 2012 at 12:18 Pointy 414k62 gold badges594 silver badges626 bronze badges asked May 22, 2012 at 12:16 JeeviJeevi 3,0426 gold badges40 silver badges61 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 14

Handlebars.js is a superset of Mustache.js. It offers all the same ability to insert JSON into templates plus additional abilities to do some basic if/then, etc. In general, I find it much easier to do templating with Handlebars.

Mustache is very much about not having any logic in your template at all. Every piece that gets inserted into it should be pre-chewed so there's no need for any logic. I find that to not at all be realistic.

Just realized that I didn't answer one of your questions. No, it is not necessary to read about Mustache before using Handlebars. The Handlebars documentation is sufficient on its own.

P.S. One of our favorite Handlebars features is "helpers" which allow you to create new keywords in the language for specific things (for example, we use one to format numbers and sometimes replace them with "N/A" for zero values).

P.P.S. A great way to try out Handlebars and see some templates in action (and also to play with your own templates and JSON) is http://www.tryhandlebarsjs.com/

According to this website (which also provides a benchmark between the two)

handlebars.js is a compiled mustache implementation with some additional features

本文标签: javascriptRelation between HandleBar js and Mustache jsStack Overflow