Permalink
Browse files

Fix #547 - _.templateSettings is unchanged by custom settings.

  • Loading branch information...
1 parent e80bbe6 commit d17834aeb01c01fa340a931636f43dfef084d149 @braddunbar braddunbar committed Apr 10, 2012
Showing with 7 additions and 1 deletion.
  1. +6 −0 test/utility.js
  2. +1 −1 underscore.js
View
@@ -186,4 +186,10 @@ $(document).ready(function() {
strictEqual(_.template(s)(data), 'x')
});
+ test('#547 - _.templateSettings is unchanged by custom settings.', function() {
+ ok(!_.templateSettings.variable);
+ _.template('', {}, {variable: 'x'});
+ ok(!_.templateSettings.variable);
+ });
+
});
View
@@ -952,7 +952,7 @@
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_.template = function(text, data, settings) {
- settings = _.extend(_.templateSettings, settings);
+ settings = _.defaults(settings || {}, _.templateSettings);
// Compile the template source, taking care to escape characters that
// cannot be included in a string literal and then unescape them in code

0 comments on commit d17834a

Please sign in to comment.