<script id="template" type="x-tmpl-mustache"> <p>Use the <strong>{{power}}</strong>, {{name}}!</p> </script>
//Grab the inline template var template = document.getElementById('template').innerHTML; //Parse it (optional, only necessary if template is to be used again) Mustache.parse(template); //Render the data into the template var rendered = Mustache.render(template, {name: "Luke", power: "force"}); //Overwrite the contents of #target with the rendered HTML document.getElementById('target').innerHTML = rendered;
References :
https://www.sitepoint.com/overview-javascript-templating-engines/
Keywords :
Template , String , HTML