Until version 0.8 it was possible to use the regular Handlebars way for defining iterative block helpers such as the popular each_with_key
, defined, e.g., here
And just as I was about to give up, I figure it out. It's in fact easier and prettier now in 0.8 than it was before. The following seems to work great:
JS:
UI.registerHelper('addKeys', function (all) {
return _.map(all, function(i, k) {
return {key: k, value: i};
});
});
HTML:
{{#each addKeys obj}}
<div>
{{key}}: {{value}}
</div>
{{/each}}