Experiencing issues with Prettier-plugin-liquid in Dawn theme, any solutions?

Experiencing issues with Prettier-plugin-liquid in Dawn theme, any solutions?

coffeedev
Shopify Partner
2 0 1

I've recently updated pretier-plugin to the latest version, it seems that it found an issue within the header.liquid file for the Dawn theme.

I've checked the default dawn theme file and it's identical to mine, anyone had this before?

LINE 140:

<{% if section.settings.enable_sticky_header %}sticky-header{% else %}div{% endif %} class="shadow header-wrapper color-{{ section.settings.color_scheme }} gradient{% if section.settings.show_line_separator %} header-wrapper--border-bottom{% endif %}">

ERROR message:
Line 140, col 2: expected a letter, "{{", "wbr" (case-insensitive), "track" (case-insensitive), "source" (case-insensitive), "param" (case-insensitive), "meta" (case-insensitive), "link" (case-insensitive), "keygen" (case-insensitive), "input" (case-insensitive), "img" (case-insensitive), "hr" (case-insensitive), "embed" (case-insensitive), "command" (case-insensitive), "col" (case-insensitive), "br" (case-insensitive), "base" (case-insensitive), "area" (case-insensitive), "svg", "style", or "script"
Reply 1 (1)

nbamvp
Shopify Partner
4 0 3

Hi, I was getting the same problem when formatting liquid in the header. I think it was because liquid cannot be used to generate actual tags maybe? so having the opening {% straight after a < threw the error but I am no expert.

The way I fixed it was to just make a variable like so:

{% assign sticky_tag = 'div' -%}
{%- if section.settings.enable_sticky_header %}{% assign sticky_tag = 'sticky-header' %}{% endif %}
<{{ sticky_tag }} class="header-wrapper color-{{ section.settings.color_scheme }} gradient{% if section.settings.show_line_separator %} header-wrapper--border-bottom{% endif %}">

then the same error was thrown with the closing tag but it can be replaced with just:

</{{ sticky_tag }}>

Not sure if it is correct, but it worked for me... 😁