Skip to content

Conversation

nknapp
Copy link
Contributor

@nknapp nknapp commented Jan 14, 2023

" and ' are not allowed as literal segment. At best, they may be used as LiteralExpression as parameter for helpers, but a template like

{{'my id containing spaces'}} 

just does not parse

nknapp and others added 2 commits January 14, 2023 22:25
`"` and `'` are not allowed as literal segment. At best, they may be used as `LiteralExpression` as parameter for helpers, but a template like 

```
{{'my id containing spaces'}} 
``` 

just does not parse
Copy link
Member

@jaylinski jaylinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@papasmile
Copy link
Contributor

@nknapp
Copy link
Contributor Author

nknapp commented Feb 7, 2023

Yes, I actually didn't try the statement that I wrote above 😳

I meant this

https://handlebarsjs.com/playground.html#format=1&currentExample=%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

  • This errors: {{ hello."my world" }}
  • This works: {{ 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...

@nknapp
Copy link
Contributor Author

nknapp commented Feb 7, 2023

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.

@nknapp nknapp closed this Feb 7, 2023
@jaylinski jaylinski deleted the nknapp-patch-1 branch September 23, 2023 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants