liquid
liquid copied to clipboard
Add where/reject option to for
Hi,
In Shopify, we often need to loop through blocks and ignore some depending on conditions. It would be very handy if for loops would support an extra "where" and "reject" filters:
{%- for block in section.blocks where: 'settings.image' -%}
Only loop through blocks whose image is defined
{%- else -%}
Show placeholder
{%- endfor -%}
This would make the syntax much more expressive and would remove a lot of useless creation of temporary variables (which are often source of hard to track bug when they override already existing variables).