We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi!
I'd like to use block parameters in my own helper. In my example scenario I want to add two values and "store" them as block variable "result" with a "let" helper (inspired by the ember.js let helper https://guides.emberjs.com/release/components/helper-functions/#toc_the-let-helper). Looking at the handlebars "with"-helper (https://github.com/handlebars-lang/handlebars.js/blob/master/lib/handlebars/helpers/with.js) I tried to create the following code where I expect result to be 3.
3
In my case this fails, but I can't figure out how blockParams works exactly and I could not find any lightncandy docs for it. I know that I could switch the context and just use {{.}}, but I hate the context switching feature and want to explicitely name the new I looked at the docs here https://zordius.github.io/HandlebarsCookbook/0022-blockhelper.html and here https://zordius.github.io/HandlebarsCookbook/9002-helperoptions.html .
Any help would be appreciated. Thanks!
$template = <<<EOF {{#let (add 1 2) as |result|}} Result is: {{result}} {{/let}} EOF; $phpStr = LightnCandy::compile($template, [ 'flags' => LightnCandy::FLAG_HANDLEBARS, 'helpers' => [ "add" => function ($a, $b) { return $a + $b; }, 'let' => function ($context, $options) { return $options['fn']($context, [ "data" => $options['data'], "blockParams" => [$context] ]); } ] ]);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi!
I'd like to use block parameters in my own helper. In my example scenario I want to add two values and "store" them as block variable "result" with a "let" helper (inspired by the ember.js let helper https://guides.emberjs.com/release/components/helper-functions/#toc_the-let-helper). Looking at the handlebars "with"-helper (https://github.com/handlebars-lang/handlebars.js/blob/master/lib/handlebars/helpers/with.js) I tried to create the following code where I expect result to be
3
.In my case this fails, but I can't figure out how blockParams works exactly and I could not find any lightncandy docs for it. I know that I could switch the context and just use {{.}}, but I hate the context switching feature and want to explicitely name the new I looked at the docs here https://zordius.github.io/HandlebarsCookbook/0022-blockhelper.html and here https://zordius.github.io/HandlebarsCookbook/9002-helperoptions.html .
Any help would be appreciated. Thanks!
The text was updated successfully, but these errors were encountered: