Another Handlebars Expression Helper
In response to this StackOverflow question: http://stackoverflow.com/questions/26877357/evaluating-expression-in-function-call
HTML
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script id="template" type="text/x-handlebars-template">
{{{checkbox id}}}
</script>
<div id="rendered"></div>
JavaScript
// Expression Helper
Handlebars.registerHelper('checkbox', function (id) {
return '<input type="checkbox" name=id id=id >';
});
var template = Handlebars.compile($("#template").html());
alert($("#template").html());
$("#rendered").html(template(
{
"id": "MyCheckboxID"
}
));