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

Svelte6 readiness: Why are quotes required for Pug attributes? #660

Open
njreid opened this issue Nov 7, 2024 · 2 comments
Open

Svelte6 readiness: Why are quotes required for Pug attributes? #660

njreid opened this issue Nov 7, 2024 · 2 comments

Comments

@njreid
Copy link

njreid commented Nov 7, 2024

Currently, Pug syntax embedded in Svelte template tags requires quoted values, enclosing Javascript expressions in braces:

body
  p(class:name!="{highlighted}") Example

This isn't a Pug requirement. The following Pug syntax would be fine:

body
  p(class:name={highlighted} Example

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?

@Conduitry
Copy link
Member

What happens if the expression has spaces in it, or any other special characters? How does this get parsed then?

@njreid
Copy link
Author

njreid commented Nov 15, 2024

Any spaces between the braces should be ok, right?

p(class:name={something.length > 0}) Example Test

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

No branches or pull requests

2 participants