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

Fix split filter compatibility issues #135

Merged
merged 6 commits into from
Dec 14, 2023
Merged

Fix split filter compatibility issues #135

merged 6 commits into from
Dec 14, 2023

Conversation

jg-rp
Copy link
Owner

@jg-rp jg-rp commented Dec 13, 2023

This PR adds a new implementation of the split filter which resolves some compatibility issues when compared to Shopify/Liquid (the reference implementation).

The new split filter will be enabled by default when using liquid.future.Environment, and can optionally be registered with liquid.Environment for those that don't mind the behavioural change. Like this:

from liquid import Environment
from liquid.future.filters import split

env = Environment()
env.add_filter("split", split)

template = env.from_string('{% assign items = "" | split: "," %}{{items | size}}')
print(template.render())

Closes #134.

@jg-rp jg-rp merged commit a60531c into main Dec 14, 2023
42 checks passed
@jg-rp jg-rp deleted the split-filter branch December 14, 2023 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Splitting strings produces different values than the reference Ruby library
1 participant