One subtle but significant difference is in the way the two libraries approach scope. Mustache will fall back to parent scope if it can't find a variable within the current context; Handlebars will return a blank string.
This is barely mentioned in the GitHub README, where there's one line for it:
Handlebars deviates from Mustache slightly in that it does not perform recursive lookup by default.
However, as noted there, there is a flag to make Handlebars behave in the same way as Mustache -- but it affects performance.
This has an effect on the way you can use #
variables as conditionals.
For example in Mustache you can do this:
{{#variable}}<span class="text">{{variable}}</span>{{/variable}}
It basically means "if variable exists and is truthy, print a span with the variable in it". But in Handlebars, you would either have to:
- use
{{this}}
instead
- use a parent path, i.e.,
{{../variable}}
to get back out to relevant scope
- define a child
variable
value within the parent variable
object
More details on this, if you want them, here.