Skip to content

Commit

Permalink
Merge pull request #7 from curran/dashes
Browse files Browse the repository at this point in the history
Handle dashes
  • Loading branch information
curran authored Nov 11, 2016
2 parents 07321aa + b275e87 commit 2b4d531
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var parseString = (function (){

// This regular expression detects instances of the
// template parameter syntax such as {{foo}} or {{foo:someDefault}}.
var regex = /{{(\w|:|\s)+}}/g;
var regex = /{{(\w|:|\s|-)+}}/g;

return function (str){
if(regex.test(str)){
Expand Down
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ describe("json-template", function() {
assert.equal(template({ firstName: "Jane", lastName: "Doe" }), "Hello Jane Doe, how are you ?");
});

it("should handle dashes in defaults", function() {
var template = parse("{{startTime:now-24h}}");
assert.deepEqual(template.parameters, [{ key: "startTime", defaultValue: "now-24h" }]);
assert.equal(template({ startTime: "now-48h"}), "now-48h");
assert.equal(template(), "now-24h");
});

});


Expand Down

0 comments on commit 2b4d531

Please sign in to comment.