I would like to swap our template engine from ICanHas (Mustache) to Hogan. ICanHas allows you to define templates in a script block. Is it possible to do this with Hogan?
Yes. Here's a simple template in a script
tag:
<script id="hogan-tpl" type="text">
hello {{planet}}
</script>
Here's the minimal JavaScript needed that grabs the template from the script
element, compiles it with Hogan.js, and renders with the appropriate data before assigning it to the innerHTML of the body:
var template = $('#hogan-tpl').html(),
hello = Hogan.compile(template),
context = { planet: "world" },
tpl = hello.render(context);
document.body.innerHTML = tpl;