sprintf.js icon indicating copy to clipboard operation
sprintf.js copied to clipboard

Named arguments, where the key is not a single word

Open thexs-dev opened this issue 9 years ago • 4 comments

Is there any way to deal with named arguments, where the key is not a single word, like this case:

var user = {
    "First Name": "Dolly"
}
sprintf("Hello %(First Name)s", user) // Hello Dolly

(the above code produces an error)

thexs-dev avatar Nov 16 '16 12:11 thexs-dev

Yeah, I think that's doable

alexei avatar Nov 16 '16 12:11 alexei

Unfortunately I don't have time right now. I'll see if I can do it at the end of the week

alexei avatar Nov 16 '16 12:11 alexei

At a first glance, this should be easy to fix. I think the placeholder parser consumes everything but a ) but then when it checks whether it's a key, it uses a different regexp that matches alnum characters

alexei avatar Nov 16 '16 12:11 alexei

Note to self: see also #104

alexei avatar May 09 '17 15:05 alexei