I have been Tasked to use mustache template engine for the sole purpose of rendering templates while researching on how to use this i have stumbled across lambdas which i still quiet can’t catch
For example in the official mustache documentations it is mentioned usage is
Template:
{{#wrapped}}{{name}} is awesome.{{/wrapped}}
Hash:
{
"name": "Willy",
"wrapped": function(text) {
return "<b>" + text + "</b>"
}
}
Output:
<b> Willy is awesome.</b>
So the expected output is Willy is awesome but I can’t get the same output here is what I passed
{
"tId": "function",
"data": {
"name": "Vishnu",
"wrapped": "function(text) { return "<b>" + text + "</b>"; }",
}
}
Even though the template is all same I get just “Vishnu is awesome” with exception of the tags. What am i suppose to get exactly ? the text in bold or the text with tags
Am I missing something here ? How and what is the working of lambdas in this templating engine ?
In the similar fashion the other example in same documentation doesn’t even outputs the result
Reffered documentation : https://mustache.github.io/mustache.5.html
In some documentations for e.g this https://www.c-sharpcorner.com/article/getting-started-with-mustache-js/ mentions that
Lambdas are used to transform data before it is inserted into the template. A lambda is a function that takes a string as input and returns a string as output.
What does this mean ? Any help is highly appreciated