what are handlebars' lambdas and how to use them? #2066
Answered
by
jaylinski
iamstarkov
asked this question in
Q&A
|
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? |
Answered by
jaylinski
Mar 20, 2025
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 |
0 replies
Answer selected by
iamstarkov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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