-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Hi, firstly thank you for this plugin, it's a really great tool when working with Go HTML templates.
I noticed the parser falls over when template syntax exists within an HTML tag.
<button class="{{if eq .SelectedTab "docs"}}active {{end}}">
Hello world!
</button>Here is the prettier output:
[error] test.tmpl.html: SyntaxError: Unexpected closing tag "button". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (3:1)
[error] 1 | <button class="{{if eq .SelectedTab "docs"}}active {{end}}">
[error] 2 | Hello world!
[error] > 3 | </button>
[error] | ^^^^^^^^^Similarly,
<button
{{if eq .SelectedTab "docs"}}data-tab-active{{end}}
class="font-bold"
>
Hello world!
</button>[error] test.tmpl.html: SyntaxError: Unexpected closing tag "button". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (6:1)
[error] 4 | >
[error] 5 | Hello world!
[error] > 6 | </button>
[error] | ^^^^^^^^^I would expect it to be able to handle the first case, as the template syntax is within the class string. The second use case would be the preferred approach but I can understand if this is harder to parse and handle within Prettier.
Would love any insights on how to solve for this. I'm happy to contribute back as well if you can point me in the right direction.
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels