Array filters are used to work with arrays.

batch

Divides an array into multiple arrays of a given size.

Code
{% assign batches = entityview.records | batch: 2 %}
{% for batch in batches %}
<ul>
{% for item in batch %}
<li>{{ item.fullname }}</li>
{% endfor %}
</ul>
{% endfor %}
Output
<ul>
<li>John Smith</li>
<li>Dave Thomas</li>
</ul>
<ul>
<li>Jake Johnson</li>
<li>Jack Robinson</li>
</ul>

concat Added 7.0.0010

Concatenates two arrays into a single new array.

Given a single item as a parameter, concat returns a new array that consists of the original array, with the given item as the last element.

Code
Group #1: {{ group1 | join: ', ' }}
Group #2: {{ group2 | join: ', ' }}
Group #1 + Group #2: {{ group1 | concat: group2 | join: ', ' }}
Group #1 + Leslie: {{ group1 | concat: 'Leslie' | join: ', ' }}
Output
Group #1: John, Pete, Hannah
Group #2: Joan, Bill
Group #1 + Group #2: John, Pete, Hannah, Joan, Bill
Group #1 + Leslie: John, Pete, Hannah, Leslie

except

Select all the objects in an array where a given attribute does not have a given value. (This is the inverse of where.)

Code
{% assign redmond = entityview.records | except: 'address1_city', 'Redmond' %}
{% for item in redmond %}
{{ item.fullname }}
{% endfor %}
Output
Jack Robinson

first

Returns the first element of an array.

first can also be used with a special dot notation, in cases where it needs to be used inside a tag.

Code
{% assign words = "This is a run of text" | split: " " %}
{{ words | first }}
{% if words.first == "This" %}
The first word is "This".
{% endif %}
Output

This

The first word is "This".

group_by

Group the items in an array by a given attribute.

Code
{% assign groups = entityview.records | group_by: 'address1_city' %}
{% for group in groups %}
{{ group.key }}:
{% for item in group.items %}
{{ item.fullname }}
{% endfor %}
{% endfor %}
Output
Redmond:
John Smith
Dave Thomas
Jake Johnson

New York:
Jack Robinson

join

Joins the elements of an array with the character passed as the parameter. The result is a single string.

Code
{% assign words = "This is a run of text" | split: " " %}
{{ words | join: ", " }}
Output

This, is, a, run, of, text

last

Returns the last element of an array.

last can also be used with a special dot notation, in cases where it needs to be used inside a tag.

Code
{% assign words = "This is a run of text" | split: " " %}
{{ words | last }}
{% if words.last == "text" %}
The last word is "text".
{% endif %}
Output

text

The last word is "text".

order_by

Returns the elements of an array ordered by a given attribute of the elements of the array.

Optionally, you can provide desc as a second parameter to sort the elements in descending order, rather than ascending.

Code
{{ entityview.records | order_by: 'fullname' | join: ', ' }}
{{ entityview.records | order_by: 'fullname', 'desc' | join: ', ' }}
Output
Dave Thomas, Jack Robinson, Jake Johnson, John Smith
John Smith, Jake Johnson, Jack Robinson, Dave Thomas

random Added 7.0.0010

Returns a single randomly-selected item from the array.

Code
{{ group1 | join: ', ' }}
{{ group1 | random }}
Output
John, Pete, Hannah
Pete

select

Selects the value of a given attribute for each item in an array, and returns these values as an array.

Code
{{ entityview.records | select: 'address1_city' | join: ', ' }}
Output
Redmond, New York

shuffle Added 7.0.0010

Applied to an array, returns a new array with the same items, in randomized order.

Code
{{ group1 | join: ', ' }}
{{ group1 | shuffle | join: ', ' }}
Output
John, Pete, Hannah
Hannah, John, Pete

size

Returns the number of items in an array.

size can also be used with a special dot notation, in cases where it needs to be used inside a tag.

Code
{% assign words = "This is a run of text" | split: " " %}
{{ words | size }}
{% if words.size == 6 %}
The text contains 6 words.
{% endif %}
Output

6

The text contains 6 words.

take

Takes a given number of items from the array, returning the taken items.

Code
{% assign words = "This is a run of text" | split: " " %}
{{ words | take: 3 | join: ', ' }}
Output

This, is, a

then_by Added 7.0.0010

Adds additional subsequent ordering to an array already ordered by order_by.

Optionally, you can provide desc as a second parameter to sort the elements in descending order, rather than ascending.

Code
{{ entityview.records | order_by: 'address1_city' | then_by: 'fullname' | join: ', ' }}
{{ entityview.records | order_by: 'address1_city' | then_by: 'fullname', 'desc' | join: ', ' }}
Output
Dave Thomas, Jack Robinson, Jake Johnson, John Smith
John Smith, Jake Johnson, Jack Robinson, Dave Thomas

where

Select all the objects in an array where a given attribute has a given value.

Code
{% assign redmond = entityview.records | where: 'address1_city', 'Redmond' %}
{% for item in redmond %}
{{ item.fullname }}
{% endfor %}
Output
John Smith
Dave Thomas
Jake Johnson