I'm trying to iterate over an array of strings in a handlebars template with builtin helper '{{#each}}'. But it doesn't work.
Simplified example:
A custom helper function which returns an array of strings:
helpers: {
arr: function () {
return ['foo', 'bar'];
}
}
The Template in which to access the helper:
{{#each arr}}
{{@index}}: {{this}}
{{else}}
default
{{/each}}
But this always prints the else case. When directly accessing the helper (without #each) it results as expected:
{{arr}} // prints => foo,bar
I somewhere read that #each needs a object to work with. I couldn't find anything about this in context of a helper in the docs - nevertheless I tried to wrap the returning array in an object in several ways. But I wasn't able to make it work.
So, how to properly access an array of strings (which comes from a helper) within a handlebars template?