Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding dot when parsing string templates #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var nargs = /\{([0-9a-zA-Z_]+)\}/g
var nargs = /\{([0-9a-zA-Z_.]+)\}/g

module.exports = template

Expand Down
6 changes: 6 additions & 0 deletions test/string-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down