what are handlebars' lambdas and how to use them? #2066
-
I found it in code https://github.com/handlebars-lang/handlebars.js/blob/master/lib/handlebars/runtime.js#L146-L148 and in README:
but there is nothing else in documentation about it. what are handlebars' lambdas and how to use them? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Mustache-style lambdas// Pseudo code
const template = compile("{{today}}");
template({
year: 1970,
today: function() {
return "Year: {{year}}"
}
}); Source: https://mustache.github.io/mustache.5.html Handlebars lambdasconst template = compile("{{today}}");
template({
year: () => 1970,
today: function () {
return `Year: ${this.year()}`;
}
}); Source: Lines 768 to 779 in f422bfd |
Beta Was this translation helpful? Give feedback.
-
@jaylinski thank you |
Beta Was this translation helpful? Give feedback.
Mustache-style lambdas
Source: https://mustache.github.io/mustache.5.html
Handlebars lambdas
Source:
handlebars.js/spec/helpers.js
Lines 768 to 779 in f422bfd