I have no idea on outputing dynamic object using handlebar

For example, two records:

[
{title: 'bird', attributes: {'could fly': true, 'eat bugs': true}},
{title: 'yarco', attributes: {'age': 34, 'sex': 'male'}}
]

so, how to iterate those attributes?

And also, there’s @last, @first in handlebar (http://handlebarsjs.com/reference.html), but it seems can not work in emberjs…
What’s wrong going on?

I really hate those guys who create awesome libraries/frameworks but also reinvent template engine!!!
laravel + blade (not smarty / twig), and also this one emberjs + handlebar (not underscore?)

I would probably solve this by writing a computed property that would transform the attributes object into an array. So,

{'could fly': true, 'eat bugs': true} 

becomes:

[
  {key: 'could fly', value: true}, 
  {key: 'eat bugs', value: true}
]

This structure is easily iterated using handlebars.

There’s a thorough discussion of this (along with the above suggestion) here: ember.js - Iterating through an Ember Object - Stack Overflow

2 Likes