Test name | Executions per second |
---|---|
Handlebars | 200307.1 Ops/sec |
Mustache | 338529.0 Ops/sec |
<script src="https://s3.amazonaws.com/builds.handlebarsjs.com/handlebars.min-v4.7.8.js"></script>
<script src="https://unpkg.com/mustache@4.2.0/mustache.min.js"></script>
var template = "<strong>This is a slightly more complicated {{thing}}.</strong>.\n{{! Just ignore this business. }}\nCheck this out:\n{{#hasThings}}\n<ul>\n{{#things}}\n<li class={{className}}>{{word}}</li>\n{{/things}}</ul>.\n{{/hasThings}}\n{{^hasThings}}\n\n<small>Nothing to check out...</small>\n{{/hasThings}}";
var context = {
thing: function() {
return "blah";
},
things: [
{"className": "one", word: "@fat"},
{"className": "two", word: "@dhg"},
{"className": "three", word:"@sayrer"}
],
hasThings: true
};
var handlebarsRenderer = Handlebars.compile(template);
Mustache.parse(template);
handlebarsRenderer(context);
Mustache.render(template, context);