Skip to content

Instantly share code, notes, and snippets.

@aanoaa
Created December 20, 2012 05:24
Show Gist options
  • Save aanoaa/4343136 to your computer and use it in GitHub Desktop.
Save aanoaa/4343136 to your computer and use it in GitHub Desktop.
Mustache = require('mustache');
var view = {
title: "Joe",
calc: function () {
return 2 + 4;
}
};
var view2 = {
results: [
{status:1},
{status:2},
]
};
var output = Mustache.render("{{title}} spends {{calc}}", view);
console.log(output);
output = Mustache.render("{{#results}}{{status}}{{/results}}", view2);
console.log(output);
var json = JSON.stringify(view2);
console.log(json);
var view3 = JSON.parse(json)
output = Mustache.render("{{#results}}{{status}}{{/results}}", view3);
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment