Meteor and handlebars #each to iterate over object

后端 未结 3 1830
旧巷少年郎
旧巷少年郎 2020-12-14 08:14

I want to use handlebars #each with an object that\'s not an array.

How do I do that? I need it to still work with meteor\'s special features with

3条回答
  •  不思量自难忘°
    2020-12-14 08:50

    It should be noted for people finding this now that the correct way to declare Handlebars helpers in Meteor as of this writing is with the UI.registerHelper method as opposed to Handlebars.registerHelper. So the above helper should look like this now:

    UI.registerHelper("arrayify", function(obj){
        result = [];
        for (var key in obj){
            result.push({name:key,value:obj[key]});
        }
        return result;
    });
    

提交回复
热议问题