Skip to content
Log in

compact - Liquid Filter Reference

On this page

Description

Removes any nil values from an list.

Property Value
Return Type list
Category lists

Examples

```liquid {% assign compacted_categories = categories | compact %}

{% for category in compacted_categories | compact -%} - {{ category }} {% endfor %} ```

Output: - Geography\n- Entertainment\n- History\n- Art & Literature\n- Science & Nature\n- Sports & Leisure

Was this article helpful?

Was this article helpful?