Skip to content

Commit

Permalink
Update marionette.itemview.md
Browse files Browse the repository at this point in the history
Updated description for 'template' function to allow for more ambiguity between versions of underscore.
  • Loading branch information
bafolts committed Sep 16, 2014
1 parent 9319c27 commit 6f52fec
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions docs/marionette.itemview.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var my_template_html = '<div><%= args.name %></div>'
var MyView = Backbone.Marionette.ItemView.extend({
template : function(serialized_model) {
var name = serialized_model.name;
return _.template(my_template_html, { variable: 'args' })({
return _.template(my_template_html)({
name : name,
some_custom_attribute : some_custom_key
});
Expand All @@ -71,12 +71,9 @@ var MyView = Backbone.Marionette.ItemView.extend({
new MyView().render();
```

Note that using a template function allows passing custom arguments into the _.template function,
including a "settings" argument, as used in the example above.
Note that using a template function allows passing custom arguments into the _.template function and allows for more control over how the _.template function is called.

According to the [Underscore docs](http://underscorejs.org/#template), using the "variable" setting
"can significantly improve the speed at which a template is able to render." Using this setting
also requires you to read data arguments from an object, as demonstrated in the example above.
For more information on the _.template function see the [Underscore docs](http://underscorejs.org/#template).

## Rendering A Collection In An ItemView

Expand Down

0 comments on commit 6f52fec

Please sign in to comment.