The standard shape of a Mustache template function is as follows:
{
"a":10,
"b":20,
"myfn": function(){
return function(text, render){
return "The cost is:" + render(text)
}
},
"currency_symbol":"£"
}The value of the parameter "text" will be the Mustache bracketed name of some part of the hash which was specified in the template ( e.g. "{{a}}" ). The purpose of the render function is to "lookup" the value of "a" in the hash and return 10 (in this case).
The insight recorded in this post is that any other simple value from the hash can be looked up and the value used in the function, for example...
return "The cost is: " + render("{{currency_symbol}}") + render(text)