From ee257522aaa55467a67a04d9b4ceae80ae3b4066 Mon Sep 17 00:00:00 2001 From: Alfonso de la Osa Date: Fri, 17 Mar 2017 13:17:11 +0000 Subject: [PATCH] adding dot when parsing string templates --- index.js | 2 +- test/string-template.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 52945bb..80c9837 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -var nargs = /\{([0-9a-zA-Z_]+)\}/g +var nargs = /\{([0-9a-zA-Z_.]+)\}/g module.exports = template diff --git a/test/string-template.js b/test/string-template.js index e279bbd..7e6e893 100644 --- a/test/string-template.js +++ b/test/string-template.js @@ -8,6 +8,12 @@ test("Named arguments are replaced", function (assert) { assert.end() }) +test("Named arguments from flattened objects are replaced", function (assert) { + var result = format("Hello {user.name}, how are you?", { "user.name": "Mark" }) + assert.equal(result, "Hello Mark, how are you?") + assert.end() +}) + test("Named arguments at the start of strings are replaced", function (assert) { var result = format("{likes} people have liked this", {