Skip to main content

has

array | has: string, string
returns boolean

Tests if any item in an array has a specific property value.

This requires you to provide both the property name and the associated value.

{% assign has_potent_potions = collection.products | has: 'vendor', "Polina's Potent Potions" %}

{{ has_potent_potions }}

Output

true
Anchor to Returns `false` when no items match the specified property value.

Returns false when no items match the specified property value.

{% assign has_potent_potions = collection.products | has: 'vendor', "Polina's Potions" %}

{{ has_potent_potions }}

Output

false
Was this page helpful?