Closed nknapp closed 1 year ago
Hi, All, not sure what you mean, actually... test referenced indeed have examples of non-array literals with quotes (L414,418).
Perhaps you meant as a property reference? i.e. array.[0].['some key']
vs array.[0].'some key'
? But that would just be incorrect JavaScript...
Yes, I actually didn't try the statement that I wrote above :flushed:
I meant this
https://handlebarsjs.com/playground.html#format=1¤tExample=%7B%22template%22%3A%22%7B%7Bhello.%5C%22my%20world%5C%22%7D%7D%5Cn%22%2C%22partials%22%3A%5B%5D%2C%22input%22%3A%22%7B%5Cn%20%20%5C%22hello%5C%22%3A%20%7B%20%5C%22my%20world%5C%22%3A%20%5C%22good%20bye%5 C%22%20%7D%2C%5Cn%7D%5Cn%22%2C%22output%22%3A%22good%20bye%5Cn%22%2C%22preparationScript%22%3A%22%2F%2F%20Handlebars.registerHelper('loud'%2C%20function(string)%20%7B%5Cn%2F%2F%20%20%20%20return%20string.toUpperCase()%5Cn%2F%2F%20%7D)%3B%5Cn%22%2C%22handlebarsVersion%22%3A%224.7.7%22%7D
{{ hello."my world" }}
{{ hello.[my world] }}
But if this works: {{ 'my id containing spaces' }}
then it looks like a bug to me.
I actually came across this, when trying to write the spec. https://handlebars-ng.knappi.org/
This falls into the category: "Should probably work differently". I will add it to the list...
closing for now, since my changes are not correct. Thanks @jaylinski and @papasmile for pointing to the tests.
Btw. I found out:
{{ 'my id containing spaces' }}
is interpreted by the parser as StringLiteral
. That's why it works, even though it does not as part of PathExpressions.
"
and'
are not allowed as literal segment. At best, they may be used asLiteralExpression
as parameter for helpers, but a template likejust does not parse