I have been trying for about an hour to get a lambda to work with the mustache.js demo. Nearly all of the examples online which demonstrate lambdas, do so by declaring the json inline with their js.
I've tried the following JSON:
{
"planet": "The be the name",
"lambda": "function() {return \"{{planet}}\"}"
}
with the following mustache:
{{lambda}}
.. with no success. Is there a way to use the mustache demo page to demonstrate lambdas?
I appreciate any help.
One does not. It's not possible to represent a lambda as JSON. Your example is just two strings, one of which happens to be a function if you eval()
it. This would work:
{
"planet": "World",
"lambda": function() { return "{{planet}}" }
}
... except that it's invalid JSON so it won't :(