yarco
October 20, 2014, 9:57am
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?
yarco
October 20, 2014, 10:10am
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?)
tcjr
October 20, 2014, 4:24pm
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: ember.js - Iterating through an Ember Object - Stack Overflow
2 Likes