On the javascript side this works great. I have an ArrayController called EntityListController and I extend it to a GamesController. I’m just not sure how the EntityList can have access to my model so it can iterate over my list of games and be passed other propeties as well.
Unless you’re adding markup specific to the games template, you should be able to re-use the entity-list template by assigning the templateName property in the associated GamesView. Same template but different controller.
I’m sorry can you provide some code with this example. I’m still just a couple of days into this whole Ember stuff and currently (at least to my knowledge) I’m not using Views. I think I see what you’re saying though. The templates should be general themselves and don’t need to be extended?
renderTemplate may work, but I’ve so far avoided doing anything like that.
You can declare a GamesView and Ember will automatically associate it with the GamesController. You aren’t required to define the views if there are no view-specific properties you wish to override.
App.GamesView = View.extend({
// Ember would look for the template at 'games' by default.
// Tell Ember to use the entityList template.
templateName: 'entityList'
});
There are many other ways of making reusable code/templates in Ember. If you’d like to describe the intended use case more, I may have better suggestions. If seems like you may want a component that renders a list of whatever you pass in, and then you could make use the component on the games page.
I avoid it just because it seems more low-level/sophisticated than necessary, and wherever possible I prefer to let Ember wire things together according to the naming conventions supported throughout the framework.
I agree it’s a bit annoying to declare a class for a single property, but using the templateName property of a view is more declarative, though you can override renderTemplate(controller, model) if you need to choose a different template according to the model.