Handlebar Helper Function: Flatten

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

ParameterTypeDescription
nestedListarrayRequired. The list of lists to flatten.

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.

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

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

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