Skip to content

Commit

Permalink
Fix jashkenas#547 - _.templateSettings is unchanged by custom settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Apr 10, 2012
1 parent e80bbe6 commit d17834a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});
2 changes: 1 addition & 1 deletion underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d17834a

Please sign in to comment.