Handlebars partial vs. render vs. template

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.

Leave a Comment