Skip to content

Orphaned {% break %} and {% continue %} #76

@jg-rp

Description

@jg-rp

Recent commits to the reference implementation have highlighted an incompatibility in the way we handle {% break %} and {% continue %} tags that appear outside of a {% for %} block.

Consider this template:

{%- if true -%}
before
{%- if true %}
hello{% break %}goodbye
{% endif -%}
after
{%- endif -%}
{% for x in (1..3) %}
{{ x }}
{% endfor %}
{% for x in (1..3) %}
{{ x }}
{% endfor %}

Ruby Liquid output in both strict and lax modes:

before
hello

Python Liquid raises a LiquidSyntaxError in strict mode and jumps over the entire outer {% if %} block in lax mode.

1

2

3


1

2

3

Not for the first time, I'm torn between strict compatibility and what I consider to be more natural, expected and consistent behaviour, even for non-dev template authors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    incompatibilityBehavioural differences between Python and Ruby LiquidwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions