Skip to content

Instantly share code, notes, and snippets.

@malev
Created March 3, 2012 18:16
Show Gist options
  • Save malev/1967208 to your computer and use it in GitHub Desktop.
Save malev/1967208 to your computer and use it in GitHub Desktop.
Mustache example
var template = "
<h1>{{header}}</h1>
{{#bug}}
{{/bug}}
{{#items}}
{{#first}}
<li><strong>{{name}}\</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}
{{#empty}}
<p>The list is empty.</p>\
{{/empty}}";
var json = {
"header": "Colors",
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
],
"empty": false
};
var output = Mustache.render(template, json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment