Fixes #372 -- preserve dynamic scope for _.template functions.

This commit is contained in:
Jeremy Ashkenas
2011-11-23 10:40:08 -05:00
parent 8c346141dc
commit 65d5d60bfa
2 changed files with 10 additions and 1 deletions

View File

@@ -915,7 +915,10 @@
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
var func = new Function('obj', '_', tmpl);
return data ? func(data, _) : function(data) { return func(data, _) };
if (data) return func(data, _);
return function(data) {
return func.call(this, data, _);
};
};
// The OOP Wrapper