Mustache is a very simple and powerful templating language

I am late to the game learning about the Mustache templating language. It is very mature, and has support for all of the languages I care about: Perl, PHP, and Javascript. I am mainly focused on using it in Javascript as it is a great way to format raw data you get via JSON into something more human consumable like HTML.

It's incredibly easy to implement and get started with. A single include loads the entire zero-dependency library. As of v4.2.0 the library is tiny, clocking in at only 25k. Once loaded Mustache.render(template_str, data_obj) gets you a formatted string. A big selling point is the ease of installation and use. You can be up and running with Mustache.js in less than 5 minutes.

<script src="/js/mustache.min.js"></script>
var data = { name: "Jason", animal: "Kitten" };
var str  = Mustache.render("<p>Hello {{name}}, I hear you like {{animal}}s</p>", data);

I liked it so much I wrote up a Mustache sandbox to allow me to play around with the templating system live. The template syntax is a little archaic, but it is workable.

Note: They even have Arduino support, which I need to test.



Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 216.73.216.119
To prevent spam please submit by clicking the kitten: