liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Add where/reject option to for

Open bakura10 opened this issue 3 years ago • 0 comments

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).

bakura10 avatar Jul 11 '22 06:07 bakura10