except - Liquid Filter Reference - 1.1.0

Filter Name except
Group Arrays
Version 1.1.0

Description

Returns all items in the array where the supplied property does not equal the supplied value

Examples

When both a property and value are supplied, it removes items from the array that match the supplied property and value:
{% new List products = '[{"name":"Fridgetastic 3000","type":"whitegoods","new":false},{"name":"Coldinator 500","type":"whitegoods","new":false},{"name":"Geronimo 9000","type":"computers","new":false},{"name":"Y2K Amaze","type":"computers","new":true},{"name":"Elephant","type":"animals","new":false}]' %}

{{ products | except: "type", "whitegoods" | pluck: "name" | join: ", " }}
Geronimo 9000, Y2K Amaze, Elephant
When only a property is supplied, it removes items from the array where the supplied property is a truthy value:
{% new List products = '[{"name":"Fridgetastic 3000","type":"whitegoods","new":false},{"name":"Coldinator 500","type":"whitegoods","new":false},{"name":"Geronimo 9000","type":"computers","new":false},{"name":"Y2K Amaze","type":"computers","new":true},{"name":"Elephant","type":"animals","new":false}]' %}

{{ products | except: "new" | pluck: "name" | join: ", " }}
Fridgetastic 3000, Coldinator 500, Geronimo 9000, Elephant
When used in a chain, it is possible to filter out multiple conditions by chaining the filter:
{% new List products = '[{"name":"Fridgetastic 3000","type":"whitegoods","new":false},{"name":"Coldinator 500","type":"whitegoods","new":false},{"name":"Geronimo 9000","type":"computers","new":false},{"name":"Y2K Amaze","type":"computers","new":true},{"name":"Elephant","type":"animals","new":false}]' %}

{{ products | except: "type", "whitegoods" | except: "type": "computers" | pluck: "name" | join: ", " }}
Elephant

Back to Filter List

Back to Liquid Reference for 1.1.0

 

 
Back to Documentation