liquid icon indicating copy to clipboard operation
liquid copied to clipboard

{%- schema -%} whitespace control

Open bigskillet opened this issue 4 years ago • 4 comments

This works:

{%- schema -%}
  {
    "name": "Main",
    "settings": []
  }
{% endschema %}

...but adding whitespace control to the closing tag triggers a warning, 'schema' tag was never closed.

{%- schema -%}
  {
    "name": "Main",
    "settings": []
  }
{%- endschema -%}

Is it not possible to use whitespace control on {% schema %} tags?

bigskillet avatar Nov 11 '21 16:11 bigskillet

Does this come back as a SyntaxError? Might be a Liquid problem.

EDIT: yes it comes back as a SyntaxError.

charlespwd avatar Nov 11 '21 17:11 charlespwd

Might have to do with the fact that the schema gets stripped away from the file.

charlespwd avatar Nov 11 '21 17:11 charlespwd

Yes, SyntaxError.

bigskillet avatar Nov 11 '21 17:11 bigskillet

Any movement here? This is causing issues with conditionally rendering sections. If I have something like the following:

{%- if condition -%}
  <div>actually render something</div>
{%- endif -%}
{% schema %}
{
  "tag": "section",
  "class": "section",
  ...
}
{% endschema %}

and

/** CSS somewhere */

.section:empty {
   display: none
 }

The section is not "empty" although everything that I have control over is outputting nothing, making it impossible with shopify's JSON templates to conditionally "hide" a section based on settings within that section.

image

Edit: confirmed adding the whitespace control only to the opening tag does not resolve. Also confirmed that there is no new line at EOF that could be causing the whitespace.

pm-zr avatar Jun 10 '22 16:06 pm-zr