Arrays

Working With Arrays

These filters help you in working with arrays.

 

AddToArray

Show Details
Server: v13.0

Add a new item to an existing array.

 

AddToDictionary

Show Details
Server: v13.0

Takes an existing (or empty) dictionary and returns a new dictionary with the added key and value.

 

AllKeysFromDictionary

Show Details
Server: v13.0

Retrieves all keys that exist in the dictionary object and returns them in an array.

 

Contains

Show Details
Server: v8.0 Mobile: v1.0

The contains filter returns true if the specified value is in the array

 

Distinct

Show Details
Server: v13.0

Takes an array as input and returns the distinct (unique) elements of the array.

 

First

Show Details
Server: v1.0 Mobile: v1.0

Returns the first item from an array/collection.

 

GroupBy

Show Details
Server: v13.0

Takes a collection of items and groups them by the specified property tree value.

 

Index

Show Details
Server: v7.0 Mobile: v1.0

Provides an easy way to retrieve an item from an array using its index when chaining filters.

 

Indexer

Show Details
Server: v7.0

Returns the item at the specified index location in an array. Note that array numbering starts from zero, so the first item in an array is referenced with [0].

 

Join

Show Details
Server: v1.0 Mobile: v1.0

Combines the properties of an array with the character passed as the parameter.

 

Last

Show Details
Server: v1.0 Mobile: v1.0

Returns the last item from an array/collection.

 

Map

Show Details
Server: v1.0 Mobile: v1.0

Takes a property of the array as a parameter and creates a string out of each array property value.

 

OrderBy

Show Details
Server: v10.0 Mobile: v1.0

Orders a collection of elements by the specified property tree and returns a new collection in that order.

 

RemoveFromDictionary

Show Details
Server: v13.0

Removes the specified key from a dictionary of keys and values.

 

Select

Show Details
Server: v4.0 Mobile: v1.0

Returns a single property from an object.

 

Shuffle

Show Details
Server: v4.0 Mobile: v1.0

Randomizes the order of an array. Useful for ads on a homepage where you'd like a different ad to be first for each visit.

 

Size

Show Details
Server: v1.0 Mobile: v1.0

Provides the number of items in the array.

 

Sort

Show Details
Server: v1.0 Mobile: v1.0

Sorts the array/collection based on the property provided (note: does not work with attribute values).

 

SortByAttribute

Show Details
Server: v5.0

Sorts an array of items based on a attribute value.

 

Sum

Show Details
Server: v13.0

Performs a mathmatical summation of all numeric values in an array and outputs the result.

 

Uniq

Show Details
Server: v8.0 Mobile: v1.0

Takes a collection of values and returns only the unique set of those values.

 

Where

Show Details
Server: v4.0 Mobile: v1.0

This filter allows you to filter a collection of items by a key and value.

Array Filters In Action

Reading through the filters above you might question the value of many of them. For instance what good is the 'Map' filter when it just returns a string of array values all smashed together (Avalon CampusTacoma CampusCorolla Campus). The power comes when you chain these filters together. Consider the kitchen sink example below.

{% assign sortedCampuses = Campuses | Sort:'Name' %}
{{ sortedCampuses | Map:'Name' | Join:', ' | ReplaceLast:',',' and' }}

Output:
Avalon Campus, Corolla Campus and Tacoma Campus