Inconsistent {% continue %} Behavior in Snippets Between Shopify Liquid and LiquidJS
Closed this issue ยท 2 comments
The behavior of {% continue %}
inside snippets seems to differ between Shopify Liquid and LiquidJS. In Shopify Liquid, {% continue %} effectively acts as an "early return" from the snippet, preventing any further code in the snippet from rendering. However, in LiquidJS, {% continue %}
behaves as it would inside a loop, causing the loop in the parent context to skip to the next iteration.
Steps to Reproduce:
- Create a Liquid snippet (example-snippet.liquid):
{% continue %}
<p>This part of the snippet should be skipped</p>
- Use the snippet in a layout/section with a parent loop in LiquidJS:
{% for i in (1..3) %}
<p>Loop iteration: {{ i }}</p>
{% render 'example-snippet' %}
<p>This code will be skipped in LiquidJS, but not Shopify Liquid</p>
{% endfor %}
Expected Behaviour (based on Shopify Liquid):
<p>Loop iteration: 1</p>
<p>This code will be skipped in LiquidJS, but not Shopify Liquid</p>
<p>Loop iteration: 2</p>
<p>This code will be skipped in LiquidJS, but not Shopify Liquid</p>
<p>Loop iteration: 3</p>
<p>This code will be skipped in LiquidJS, but not Shopify Liquid</p>
What I actually get with LiquidJS is this:
<p>Loop iteration: 1</p>
<p>Loop iteration: 2</p>
<p>Loop iteration: 3</p>
I know that this may seem like a bit of an edge case, but I've seen devs using {% continue %}
in Snippets as an early return fairly commonly so should probably be fixed
Seems include
and render
behaves differently. include
in liquidjs is correct skipping the rest of for
body, but continue
in snippets called by render
should only skip its content.
๐ This issue has been resolved in version 10.19.1 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐