Permalink
Browse files

Merge pull request #427 from jugglinmike/template-context

Set context of template method to layout instance
  • Loading branch information...
2 parents 2e242e2 + 1683952 commit e6a399699d738fa36e296e66d2675166aee5c6a6 @tbranyen committed Mar 7, 2014
Showing with 12 additions and 1 deletion.
  1. +1 −1 backbone.layoutmanager.js
  2. +11 −0 test/spec/views.js
View
2 backbone.layoutmanager.js
@@ -871,7 +871,7 @@ var defaultOptions = {
// By default, render using underscore's templating and trim output.
renderTemplate: function(template, context) {
- return trim(template(context));
+ return trim(template.call(this, context));
},
// By default, pass model attributes to the templates
View
11 test/spec/views.js
@@ -2317,3 +2317,14 @@ test("Modifications to options after initialization should not modify a view", 1
options.option = "changedValue";
equal(layout.options.option, "value");
});
+
+test("template method context", 1, function() {
+ var layout = new Backbone.Layout({
+ template: function() {
+ equal(this, layout);
+ return "";
+ }
+ });
+
+ layout.render();
+});

0 comments on commit e6a3996

Please sign in to comment.