Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jg-rp opened this issue Sep 11, 2022 · 0 comments
Open

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

jg-rp opened this issue Sep 11, 2022 · 0 comments
Labels
incompatibility Behavioural differences between Python and Ruby Liquid wontfix This will not be worked on

Comments

@jg-rp
Copy link
Owner

jg-rp commented Sep 11, 2022

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.

@jg-rp jg-rp added the incompatibility Behavioural differences between Python and Ruby Liquid label Sep 11, 2022
@jg-rp jg-rp added the wontfix This will not be worked on label Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatibility Behavioural differences between Python and Ruby Liquid wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant