Permalink
Browse files

Set context of template method to layout instance

  • Loading branch information...
1 parent a5f865d commit 16839523447aa03a6c630b8dea658a7b93ef1965 @jugglinmike jugglinmike committed Mar 7, 2014
Showing with 12 additions and 1 deletion.
  1. +1 −1 backbone.layoutmanager.js
  2. +11 −0 test/spec/views.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
@@ -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 1683952

Please sign in to comment.