Use Twig's default filter in place of the ternary operator

Submitted by charles on

Instead of using the ternary operator to set a value or a default if that value doesn't exist, Twig's "default" filter provides a more compact and readable way of doing so. For example:

{% set alignment = alignment ? 'pagination--' ~ alignment : 'pagination--center' %}

Becomes:

{% set alignment = 'pagination--' ~ alignment|default('center') %}