only - Liquid Filter Reference - 1.0.0
Filter Name | only |
Group | Arrays |
Version | 1.0.0 |
Description
Returns all items in the array where the supplied property equals one of the supplied values
Examples
When both a property and value are supplied, it returns items from the array that match the supplied property and value:
{{ products | only: "type", "whitegoods" | pluck: "name" | join: ", " }}
Fridgetastic 3000, Coldinator 500
When multiple values are supplied, it returns items from the array where the supplied property equals one of the supplied values:
{{ products | only: "type", "whitegoods", "computers" | pluck: "name" | join: ", " }}
Fridgetastic 3000, Coldinator 500, Geronimo 9000, Y2K Amaze
When only a property is supplied, it returns items from the array where the supplied property is a truthy value:
{{ products | only: "new" | pluck: "name" | join: ", " }}
Y2K Amaze
Back to Liquid Reference for 1.0.0
Back to Documentation