-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Split filter doesn't behave as I would expect? #862
Comments
This is expected behaviour, as far as I can tell. You get the same result with the |
That seems so wrong. Reading about it here, split seems straight up maddening. For my use case, this behavior will probably be OK. I had to add a separator and additional character to the end to force the correct length and just ignore the last value. Probably no way of passing a "limit" value to fix this? Looks like passing a negative value for the limit gets me close to what I would expect. Then there's just the null string returning an empty array that I wouldn't expect. |
It just feels wrong for your use case. The behaviour makes more sense for the case where you are splitting on separators between words, where you don't want empty words from multiple separators that are together. |
Well... to be fair, I am doing something a little crazy. I wrote a snippet that takes html and splits it on tags. For example: <h1>Hello world!</h1><p>This is a test.</p> Returns: ["","Hello world!","<p>This is a test.</p>"] So now I can do something like a page with that html (allowing the content editors to easily modify the html), and then throw it into a popup where the Another (probably better example) is using it for product tabs. So they can use Gives me a lot of flexibility. |
I'm not a fan of how Ruby implements |
I am not sure if this is the right place to report this issue, but Shopify's split filter seems to remove all null strings after the split.
This liquid results in
["ab"]
and not the["ab","","","",""]
that I would expect.This liquid prints
1
. So it's not the json filter.The text was updated successfully, but these errors were encountered: