Usually for a {{#each}} block, we can set the value directly in it like: {{#each users}}:
users: [
{name: 'foo'},
{name: 'bar'}
]
What I need to do is do be able to set the {{#each}} iteration value from a helper.
I have tried with this helper:
Handlebars.registerHelper('myHelper', function () {
return new Handlebars.SafeString('users');
});
## also tested with:
Handlebars.registerHelper('myHelper', function () {
return 'users';
});
and in my view:
{{#each (myHelper)}} # and {{#each myHelper}}
<p>{{name}}</p>
{{/each}}
But nothing get shown. Any help is much appreciated!
This might work:
{{#each (lookup . (myHelper))}}
But you also have to make sure that you are returning the name of your property from the helper. Currently, it's users in the helper and user in the object.
Thanks a lot @nknapp 馃 you're the man
Most helpful comment
This might work:
But you also have to make sure that you are returning the name of your property from the helper. Currently, it's
usersin the helper anduserin the object.