I have no idea on outputing dynamic object using handlebar


#1

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?


#2

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?)


#3

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: http://stackoverflow.com/questions/19336461/iterating-through-an-ember-object