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

Self-closing tags should always be required in Antlers #1275

Open
o1y opened this issue Dec 4, 2024 · 4 comments
Open

Self-closing tags should always be required in Antlers #1275

o1y opened this issue Dec 4, 2024 · 4 comments

Comments

@o1y
Copy link

o1y commented Dec 4, 2024

Right now, self-closing tags in Antlers aren't strictly enforced. This means that when you use a tag, you don't have to close it, like here {{ partial:button label="Foo" }}.

However, if you mix both versions in an Antlers template, it can lead to some incorrect output.

Invalid ❌

{{ partial:button label="Foo" }}

{{ partial:button label="Foo" }}
  {{ slot:attributes }}
    foo="Bar"
  {{ /slot:attributes }}
{{/ partial:button }}

Correct ✅

{{ partial:button label="Foo" /}}

{{ partial:button label="Foo" }}
  {{ slot:attributes }}
    foo="bar"
  {{ /slot:attributes }}
{{/ partial:button }}

Since the self-closing version is pretty hidden in the Antlers docs (and isn’t mentioned in the documentation for the partial tag itself), figuring out the cause of the faulty rendering in complex templates can take a really long time :)

Either you force self-closing tags through the parser, or make it clearer in the documentation.

@jasonvarga
Copy link
Member

Forcing tags to be self closing will cause more problems than the few situations where this is an issue.

@o1y
Copy link
Author

o1y commented Dec 5, 2024

Yeah, maybe then just support both versions or throw an Antlers exception, when you mix between single and pair tags? Right now it’s a bit confusing when you use both versions in your template and then nothing gets rendered.

@jasonvarga
Copy link
Member

@JohnathonKoster Could that be an option? Throw an exception when there's an ambiguous closing tag situation?

@JohnathonKoster
Copy link

@JohnathonKoster Could that be an option? Throw an exception when there's an ambiguous closing tag situation?

This is something we could make work (I would also like this as an option).

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

3 participants