Return to Snippet

Revision: 38239
at December 29, 2010 11:16 by mattneary


Initial Code
<script type="text/javascript" src="https://github.com/janl/mustache.js/raw/master/mustache.js"></script>
<script type="text/javascript">
data = {
	name	: "Text",
	array   : ["Item1","Item2","Item3"],
	myFunction: function () {
		return function(text, render){
			text = render(text);
			replacementText = "New Text";
			return replacementText;
		}
	}
};

var template = "<h1>{{name}} vs. {{#myFunction}}{{name}}{{/myFunction}}</h1><ul>{{#array}}<li>{{.}}</li>{{/array}}</ul>";

html = Mustache.to_html(template, data);

document.write(html);
</script>

Initial URL

                                

Initial Description

                                

Initial Title
Mustache Sample Template

Initial Tags
template

Initial Language
JavaScript