Skip to content

Instantly share code, notes, and snippets.

@skoon
Created April 6, 2010 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skoon/358054 to your computer and use it in GitHub Desktop.
Save skoon/358054 to your computer and use it in GitHub Desktop.
var template = "<div><h3><a>{{Title}}</a></h3><div id='{{Title}}'><ul>{{#items}}<li><a href='{{.href]}}'>{{.title}}</a><li>{{/items}}</ul></div>";
//.href doesn't work, not sure how to access the members of {{.}} in the enumerable section.
var tutorials = { Title: "Tutorials", items: [ {href: "http://foo", title: "foo"},{href:"http://bar", title: "bar"}];
Mustache.to_html(template, tutorials);
/*
should output
<div><h3><a>Tutorials</a></h3><div id='Tutorials'><ul><li><a href='http://foo'>foo</a><li><li><a href='http://bar'>bar</a><li></ul></div>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment