Introduction

The map filter allows you to apply a function to each item in a collection (such as arrays or objects), returning a new collection with the results. This filter is useful for transforming elements in a collection in a simple and efficient way.

Note: The map filter works exclusively through Automations, Campaigns, and Advanced Campaigns.

Example of use

Example of how to use the map filter to multiply each number in an array by 2:

{% set numbers = [1, 2, 3, 4, 5] %}
{% set doubled = numbers|map(n => n * 2) %}
{{ doubled|join(', ') }}

In this example, the numbers array is transformed using the map filter, which applies the multiplication function to each element. The result is a new array [2, 4, 6, 8, 10], which is then converted into a string with the numbers separated by commas.

Example Output Code