JavaScript Icon

hogan.js: Mustache compiler from Twitter

logged by @logbot 2011-12-21T22:47:00Z permalink #javascript

Hogan is a console compiler for Mustache templates, complete with a fantastic name and man page. Aiming not only for speed, Hogan boasts a parser API:

var text = "{{^check}}{{i18n}}No{{/i18n}}{{/check}}";
text +=  "{{#check}}{{i18n}}Yes{{/i18n}}{{/check}}";
var tree = Hogan.parse(Hogan.scan(text));

// outputs "# check"
console.log(tree[0].tag + " " + tree[0].name);

// outputs "Yes"

Just released on the hub, check the web site for usage.

0:00 / 0:00