Handlebars Helper Function: flatten

Transforms a list of lists into a flat list. This function is useful for normalizing nested data structures in templates.

Availability 

This helper is available in the Winter ’26 release of Marketing Cloud Next.

Syntax 

1{{flatten nestedList}}

Parameters 

ParameterTypeDescription
nestedListArrayRequired. The list of lists to flatten.

Return Value 

The function returns a new list containing all elements from the nested lists. If the input isn’t a list of lists, or if a parameter is missing or an element isn’t a list, the function throws an exception.

Usage Examples 

This example shows how to use the flatten function to flatten this example array.

1myArray = [[1, 2], [3, 4], [5]];

To flatten the array, use the flatten function, as shown in this example.

1{{flatten myArray}}

The function returns [1, 2, 3, 4, 5].