Strange behavior with {%- -%} hyphened tags. Could this be a bug in liquid itself?

Highlighted
Shopify Expert
59 0 17

Hi,

I am observing some really strange behavior when using the {%- -%} hyphened tags instead of just {% %}.

If I have this code:

{% capture shopName %}{{shop.name}} - Some text here{% endcapture %}
<span>{{shopName}}</span>

The output is:

"My Shop Name - Some text here"

If I have the same code with the hyphened tags:

{%- capture shopName -%}{{shop.name}} - Some text here{%- endcapture -%}
<span>{{shopName}}</span>

"My Shop Name- Some text here"

Notice how the blank space before the hyphen between "My Shop Name" and "Some text here" disappears.

Could this be a bug in the liquid parser or whatever component down the liquid pipeline?

Beautiful and responsive Shopify themes crafted with care at www.kabukithemes.com.
0 Likes