sveltejs / svelte-preprocess

A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
MIT License
1.76k stars 151 forks source link

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

Open njreid opened 5 days ago

njreid commented 5 days ago

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 commented 5 days ago

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