diff --git a/lib/parser.js b/lib/parser.js index 7aceef2..4da2b32 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -14,7 +14,7 @@ function Parser(keywords) { this.keywords = keywords; - this.pattern = new RegExp('\\{\\{(?:' + keywords.join('|') + ') "((?:\\\\.|[^"\\\\])*)"(?: "((?:\\\\.|[^"\\\\])*)" \\w+)? ?\\}\\}', 'gm'); + this.pattern = new RegExp('\\{\\{(?:' + keywords.join('|') + ') "((?:\\\\.|[^"\\\\])*)"(?: "((?:\\\\.|[^"\\\\])*)" \\w+)?(?: [\\w|\\.]+)*? ?\\}\\}', 'gm'); } /** diff --git a/test/fixtures/arguments.hbs b/test/fixtures/arguments.hbs new file mode 100644 index 0000000..dd73bc8 --- /dev/null +++ b/test/fixtures/arguments.hbs @@ -0,0 +1,4 @@ +

{{title}}

+

{{_ "Hello %s" name}}

+

{{_ "Hello %s. It is %s" name weekday}}

+ diff --git a/test/parser_test.js b/test/parser_test.js index 482c7bc..27c7e6b 100644 --- a/test/parser_test.js +++ b/test/parser_test.js @@ -27,5 +27,17 @@ exports.parser = { test.equal(Object.keys(result).length, 1, 'Invalid amount of strings returned'); test.done(); + }, + 'arguments': function (test) { + test.expect(1); + + var templatePath = __dirname + '/fixtures/arguments.hbs', + template = fs.readFileSync(templatePath, 'utf8'), + result = parser.parse(template); + + test.equal(Object.keys(result).length, 2, 'Invalid amount of strings returned'); + + test.done(); + } };