group_by_exp
{% assign by_price_range = products | group_by_exp: "product", "product.price > 100" %}
{% for group in by_price_range %}
{% log group.name | append: ": " | append: group.items.size | append: " products" %}
{% endfor %}Syntax
{{ array | group_by_exp: item_name, expression }}Parameter
Description
Return Value
Property
Type
Description
Examples
{% assign by_range = products | group_by_exp: "p", "p.price > 50" %}
{% for group in by_range %}
{% if group.name == true %}
{% log "Premium products: " | append: group.items.size %}
{% else %}
{% log "Budget products: " | append: group.items.size %}
{% endif %}
{% endfor %}Notes
Last updated