Skip to content

Commit

Permalink
making _.unescape be able to unescape ' and ` symbols escaped in Dec …
Browse files Browse the repository at this point in the history
…format: &jashkenas#39; and &jashkenas#96;
  • Loading branch information
ysklar committed Nov 7, 2014
1 parent 3397cad commit 007998e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@

ok(escaped.indexOf('&') !== -1, 'handles & aka &');
equal(_.unescape(str), str, 'can unescape &');

// test unescape of ' and ` symbols escaped in Dec format
equal(_.unescape("'"), "'", 'can unescape '');
equal(_.unescape("`"), '`', 'can unescape `');
});

test('template', function() {
Expand Down
3 changes: 3 additions & 0 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,9 @@
'`': '`'
};
var unescapeMap = _.invert(escapeMap);
// Also adding ' and ` symbols escaped in Dec format
unescapeMap["'"] = "'";
unescapeMap["`"] = '`';

// Functions for escaping and unescaping strings to/from HTML interpolation.
var createEscaper = function(map) {
Expand Down

0 comments on commit 007998e

Please sign in to comment.