Is it possible to use underscore.js with Mustache style function calls? The underscore.js manual has an example how to support Mustache syntax:
_.templateSettings = {
interpolate : /\{\{(.+?)\}\}/g
};
var template = _.template("Hello {{ name }}!");
template({name : "Mustache"});
=> "Hello Mustache!"
However, apart from variables mustache.js also automatically detects when the object is a function and then evaluates it. From the mustache.js manual:
var view = {
title: "Joe",
calc: function () {
return 2 + 4;
}
};
var output = Mustache.render("{{title}} spends {{calc}}", view);
However, using underscore.js to render the latter results in:
var template = _.template("{{title}} spends {{calc}}");
template(view);
"Joe spends function () {
return 2 + 4;
}"