I am having trouble trying to get a subexpression in handlebars. I have this object
{
vehicles:{
air:"airplane",
water:"boat",
land:"cars\nvans",
}
}
I have this helper
Handlebars.registerHelper('split', function(str, ch) {
if (!str) return '';
if (typeof ch !== 'string') ch = /\n/;
return str.split(ch).map(function(splitted) {
splitted.trim();
});
});
I would like to have an output like this
air/airplane
water/boat
land/cars
land/vans
With this template
{{#each vehicles}}
{{#each (split this)}}
{{../key}}/{{{this}}}
{{/each}}
{{/each}}
I debugged and the split
helpers get the values correctly, i think it has to be something with the scope of my this
Thank you very much
Well found my issue, the way to access the key
of my object in the nested #each
was not ../@key
it turns out that it should be @../key