{% set nav_active = app.request.attributes.get('_route') == 'magazine-category' and app.request.attributes.get('slug') == slug %} {% set sub_active = false %} {% for sc in subcategories %} {% if app.request.attributes.get('_route') == 'magazine-category' and app.request.attributes.get('slug') == sc.slug %} {% set sub_active = true %} {% endif %} {% endfor %} {% set branch_active = nav_active or sub_active %} {% if subcategories is empty %} {{ title }} {% else %} {% set sub_menu_id = 'mag-nav-sub-' ~ slug|replace({':': '-'}) %}
{% endif %}