Handlebars is a templating library for JavaScript.
Handlebars is a javascript template library that is, more or less, based on mustache. Handlebars uses Mustache template syntax to render templates but it also adds these features compared to Mustache:
- Handlebars templates are compiled
- Handlebars adds
#if
,#unless
,#with
, and#each
- Handlebars supports custom helpers
- Handlebars supports paths
- Allows use of
{{this}}
in blocks (which outputs the current item's string value) Handlebars.SafeString()
(and maybe some other methods)- Handlebars is 2 to 7 times faster
However Mustache supports inverted sections (i.e. if !x
...) that are not used in Handlebars
Handlebars is used in ember.js as a Templating engine, Ember.js add some additionnal builtin helpers to the vanilla Handlebars.js. express can also use handlebars when installed with the hbs option : --hbs