I'm using REST adapter with latest ember-data and latest Ember.js (RC5)
I have model Module
with following mapping:
DS.Model.extend({
type: DS.attr('string'),
url: DS.attr('string'),
text: DS.attr('string'),
header: DS.attr('string')
});
against the API which returns JSON:
{
"status": "success",
"modules": [{
"id": "123456",
"type": "video",
"url": "http://some.where.com/video.mp4"
}, {
"id": "123457",
"type": "text",
"text": "Lorem ipsum dolor sit amet ..."
}, {
"id": "123458",
"type": "feedback",
"header": "Indtast noget feedback til os."
}]
}
- As you can see modules have different types.
- There can be many objects with the same type.
- Modules are objects in array because order is important.
The issue I'm having is how to represent them in template? I need to create different views for each of them, but there is no such a thing in handlebars like if type === video then
(only boolean if which make me worries I'm tying to solve problem from the wrong way) render different view:
if type === video
{{view moduleVideo}}
if type === text
{{view moduleText}}
if type === feedback
{{view moduleFeedback}}
How to render different views for different types? Or is there a more Ember.js way to design such a thing?