You need to use a helper in your js to help handlebars understand your object:
Add to your client js
Template.registerHelper('arrayify',function(obj){
var result = [];
for (var key in obj) result.push({name:key,value:obj[key]});
return result;
});
And use (you can also use the key with {{name}}
) in your html:
{{#each arrayify myobject}}
<div title="hover here {{name}}">{{value}}</div>
{{/each}}
myobject
comes from your template:
Template.templatename.helpers({
myobject : function() {
return { john:"hello", bob: "hi there" }
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…