/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<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>
Comments
