Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit d17834aeb01c01fa340a931636f43dfef084d149 1 parent e80bbe6
@braddunbar braddunbar authored
Showing with 7 additions and 1 deletion.
  1. +6 −0 test/utility.js
  2. +1 −1  underscore.js
View
6 test/utility.js
@@ -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
2  underscore.js
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.