Skip to main content

compact

Removes any null or nilor empty values from an array.

Basic Usage

{% set my_array = ["a", "b", null, "c", nil, "d"] %}
{{ my_array | compact | join(", ") }}

Output: a, b, c, d