Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing parser to work properly with single-quotes and not just double…

… quotes
  • Loading branch information...
commit 16f8870d4c115b96f0f6751ea3923eaaff516fee 1 parent 1fc7a8e
Paul Armstrong authored
Showing with 2 additions and 2 deletions.
  1. +1 −1  lib/parser.js
  2. +1 −1  tests/parser.test.js
2  lib/parser.js
View
@@ -47,7 +47,7 @@ exports.parse = function (data, tags, autoescape) {
filter_name = part.match(/^\w+/);
if (/\(/.test(part)) {
// Faster than doing regex split on ","
- filters.push({ name: filter_name[0], args: JSON.parse('[' + part.replace(/^\w+\(|\)$/g, '') + ']') });
+ filters.push({ name: filter_name[0], args: JSON.parse('[' + part.replace(/^\w+\(|\)$/g, '').replace(/'/g, '"') + ']') });
} else {
filters.push({ name: filter_name[0], args: [] });
}
2  tests/parser.test.js
View
@@ -118,7 +118,7 @@ exports.Variable = testCase({
},
'filters with all kinds of characters in params': function (test) {
- var output = parser.parse('{{ foo|blah("01a,;?./¨œ∑´®†][{}]") }}');
+ var output = parser.parse("{{ foo|blah('01a,;?./¨œ∑´®†][{}]') }}");
test.deepEqual([
{ type: parser.TOKEN_TYPES.VAR, name: 'foo', filters: [{ name: 'blah', args: ["01a,;?./¨œ∑´®†][{}]"] }], escape: false }
], output);
Please sign in to comment.
Something went wrong with that request. Please try again.