I’m not… entirely sure what this object (which is what you’ve got, with {} around a thing)) is… not meant to do, but rather… what you’re expecting to have happen? Are you expecting the function to get called? Are you trying to pass this object to some other function?
As explained on the Mustache documentation, as you can see, the wrapped function/object will be used as part of the templating.
Lambdas
When the value is a callable object, such as a function or lambda, the object will be invoked and passed the block of text. The text passed is the literal block, unrendered. {{tags}} will not have been expanded - the lambda should do that on its own. In this way you can implement filters or caching.
Again, still unsure how this fits together. I did add a function similar to this a while back, though lost the code and forget how this works. In time I’ll need multiple functions like wrapped, once I understand the workings.
Not quite sure either… do you mean you want to augment the response data with that wrapped render function, so that it’s available in the template? In this case you might do this with Object.assign() (or as you’re using jQuery anyway, $.extend() for x-browser compatibilty):
var renderFuncs = {
'wrapped': function () {
return function (text, render) {
return '<b>' + render(text) + '</b>'
}
}
}
$.ajax({
url: '../jsonfile.json',
dataType: 'jsonp',
success: function (data) {
$.extend(data, renderFuncs)
var template = $('#resultstpl').html()
var html = Mustache.render(template, data)
$('#results').html(html)
}
})
At any rate, your approach won’t work as the $.ajax() settings object only takes the properties as described in the documentation – everything else will be ignored.