-
Notifications
You must be signed in to change notification settings - Fork 149
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
Svelte6 readiness: Why are quotes required for Pug attributes? #660
Comments
What happens if the expression has spaces in it, or any other special characters? How does this get parsed then? |
Any spaces between the braces should be ok, right? p(class:name={something.length > 0}) Example Test |
Incorrect. The |
@njreid your example in the issue's description is also incorrect. And also has a syntax error. So yes, it is a requirement for Pug to quote special characters, which include those in Svelte directives and templated attributes, because Svelte consumes HTML produced by Pug, not Pug directly. All in all I think that the quotes behavior in Svelte isn't well-thought (Pug is not the only HTML preprocessor), especially when it avoids "magical" behavior now. (The presence of quotes is too invisible to be an obvious syntax feature for the desired language curve.) And the stupid part is that there is seemingly no alternative or option to change this behavior. Posting a relevant error message so this issue pops up in searches:
|
Currently, Pug syntax embedded in Svelte template tags requires quoted values, enclosing Javascript expressions in braces:
This isn't a Pug requirement. The following Pug syntax would be fine:
Aren't the braces enough to delineate Javascript snippets?
In Svelte 6, I understand that quoted attribute will be stringified. So, the way Svelte interprets the HTML equivalent of the previous two examples will be different.
What is the reason that the quotes are currently required? Can we remove that requirement in svelte-preprocess?
The text was updated successfully, but these errors were encountered: