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

Iterating strings with for #102

Closed
jg-rp opened this issue Jan 11, 2023 · 0 comments
Closed

Iterating strings with for #102

jg-rp opened this issue Jan 11, 2023 · 0 comments
Labels
incompatibility Behavioural differences between Python and Ruby Liquid

Comments

@jg-rp
Copy link
Owner

jg-rp commented Jan 11, 2023

When looping over strings with the {% for %} tag, the reference implementation of Liquid will iterate over a one element array, where the first and only element is the string. Python Liquid will iterate through characters in the string.

Template:

{% assign foo = 'hello world' %}
{% for x in foo %}{{ x }} / {% endfor %}

Ruby Liquid Output:

hello world /

Python Liquid Output:

h / e / l / l / o /   / w / o / r / l / d / 

It appears that this is unintended behaviour for Ruby Liquid. Previously, Ruby Liquid would iterate over lines in a string, also not intended behaviour. See Shopify/liquid#1667.

@jg-rp jg-rp added the incompatibility Behavioural differences between Python and Ruby Liquid label Jan 11, 2023
@jg-rp jg-rp closed this as completed in b6bc07b Jan 12, 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
Projects
None yet
Development

No branches or pull requests

1 participant