I m working with mustache.js for the first time. All the examples I m finding seem to talk about putting everything inline, but I want my templates in external files so they can be used in multiple places. How do I do that? (I ve got jQuery in my stack, if that makes a difference.)
So say I have:
template.html
{{title}} spends {{calc}}
data.js
var data = { title: "Joe", calc: function() { return 2 + 4; } };
index.html
<script type="text/javascript" src="data.js"></script>
<div id="target"></div>
<script type="text/javascript">
var template = ?????? // how do I attach the template?
var html = Mustache().to_html(template, data);
$( #target )[0].innerHTML = html;
</script>