Closed mzachdev closed 8 months ago
This happens because we have to strike a balance between the following two things:
The heuristic we chose is that we only allow "two unclosed" or "two closing" HTML nodes inside Liquid branches. What we have here is an unclosed node and summary and it's very hard for us to tell that it actually closes much later down the file. It's also unclear how we're supposed to indent the code in this situation.
You could fix this by adding an endif and re-adding the if statement between the unclosed node and the child node.
{% # works because there's only one unclosed node here %}
{% if is_megamenu or has_dropdown %}
<details
data-hover="{{ hover_menu }}"
id="site-nav-item--{{ forloop.index }}"
class="site-nav__details"
>
{% endif %}
{% if is_megamenu or has_dropdown %}
<summary
data-link="{{ link.url }}"
aria-expanded="false"
aria-controls="site-nav-item--{{ forloop.index }}"
class="site-nav__link site-nav__link--underline{% if has_dropdown %} site-nav__link--has-dropdown{% endif %}"
>
{{ link.title }}
<svg
aria-hidden="true"
focusable="false"
role="presentation"
class="icon icon--wide icon-chevron-down"
viewBox="0 0 28 16"
>
<path d="m1.57 1.59 12.76 12.77L27.1 1.59" stroke-width="2" stroke="#000" fill="none"/>
</svg>
</summary>
{% else %}
<a
href="{{ link.url }}"
class="site-nav__link site-nav__link--underline{% if has_dropdown %} site-nav__link--has-dropdown{% endif %}"
>
{{ link.title }}
</a>
{% endif %}
:wave: this came up too often. I think I have a fix for it in https://github.com/Shopify/theme-tools/pull/253. Should be in soon :)
Describe the bug The prettier-plugin-liquid throws an error [LiquidHTMLParsingError] on a file from the Impulse theme by Archetype. The HTML tag is closed correctly, it's clearly not able to parse the code properly. The error is thrown specifically for the
<details...>
tag, which is closed all the way at the bottom of the code block.Is there a way to disable this error for this file or code block only? I'm unfamiliar with how to do that. Thanks!
Unformatted source
Debugging information