-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
ParseError on if-statement with open tag #3133
Comments
Duplicate of #2807. |
@Conduitry I don't think this is a duplicate of that item. The first example uses the P tag (hinting at the self-closing categorization), but look at the second example. This is a very interesting idea. A type of templating which is possible with old-fashioned server-side string based HTML generation, and which is not (from my very casual survey tinkering with many dozens of web frameworks) supported by common (or any?) client-side DOM-centric templating mechanisms. Is this a good idea for Svelte to add? That I don't know. |
Ah, I see, I didn't read the last example. Supporting that is not something we're interested in doing, though. Svelte needs to know about the structure of the component at compile time. When rendering in the browser, the compiled code is not just concatenating strings together to form the document, it's representing DOM elements in a tree. |
This code causes a ParseError:
The first if-statement works, the second fails with:
This is essential for being able to conditionally add start/end tags that wrap groupings of other tags, and also appears to be a bug in the parser. Most likely the parser only looks for the / character to determine the end of a tag, or can't handle an open tag without an immediate closing html tag within the block. For example, with this bug you can't do:
You can test this theory by adding a
</p>
to the offending block so that it matches the first if-statement which passes.Even if there's a way to work around this, the parse error is invalid since the if-statements are not part of the resulting HTML so shouldn't cause an error in parsing.
The text was updated successfully, but these errors were encountered: