Skip to content

Find Index ​

Last updated View as Markdown

You get the index of the first item of an array with a matching property, or nil when none is found. The first index is 0. The match is the same as for find.

liquid
{{ array | find_index: property, value }}

Example ​

Data
json
{
  "products": [
    { "title": "Hat", "available": true, "type": "Accessory" },
    { "title": "Tee", "available": false, "type": "Clothing" },
    { "title": "Cap", "available": true, "type": "Accessory" }
  ]
}
liquid
{{ products | find_index: 'type', 'Clothing' }}

Output

html
1