liquid
liquid copied to clipboard
Nested search in where filter
This PR allows nested search in where filter.
{% assign blocks = section.blocks | where: 'settings.some_setting' %}
{% assign blocks = section.blocks | where: 'settings.some_setting', 'blue' %}
Resolves #1388
This would be really nice in sort, too. I have a date.start
I'd like to sort by, and item.dig(*property.split('.', -1))
would work very well there too I'd think.
This shouldn't bring any breaking changes to Shopify, but could bring breaking changes to other platforms using Liquid, as it won't consider attributes with dots.
I'm not sure if that is actually the case. Doesn't Shopify support JSON metafield types? If the
where
filter were used on some parsed json blob, then I would think it could end up filtering on keys with a period in them.
In that case, the input
would be a string, and this filter shouldn't do anything then?
I don't mean storing JSON in a string type field, I mean there is native support for JSON metafield types. The primary reason for that json type is so the parsed json is made accessible to liquid, meaning it could be arrays of hashes with keys that could have a period in it.
I don't mean storing JSON in a string type field, I mean there is native support for JSON metafield types. The primary reason for that json type is so the parsed json is made accessible to liquid, meaning it could be arrays of hashes with keys that could have a period in it.
Got it. Should we cover that case?
Does it make sense to add this nested feature to other filters, such as sort
, uniq
etc?
Opened a new PR which solves this in a way better way: https://github.com/Shopify/liquid/pull/1749