The Fire Up Ember.js screencast uses partial
, template
, render
to render templates within templates, but I'm still not sure I know which one to use when.
In the same screencast the partial
is explained as using the context and all data relative to the current controller, while render
uses the the specified controller's matching template, context etc:
Can someone please clarify the differences between partial
, template
, render
and when (examples) to use which?
The way I understand it, the way they break down is like this:
"render" gives you an entire view/controller/template context of its own to work with.
An example will be a top navigation that includes dynamic pieces. The content will be maintained within a TopNavController and inserted into the application template using "render"
"partial" will insert a template, but that template will be using the current context instead of its own. Partial is also a newer part of the framework, meant to replace using template to some extent.
An example would be showing a list of users and having each user be a relatively complicated piece in the list (avatar, name, email, etc) you can just loop through the list and insert the partial based in the context of each user.
"template" just inserts the template using the current context. I believe it's not good style though to use template to render pieces inside of a template, you should rather use "partial" although template will work the same way for most cases.