{% macro renderCollectionWithPrimaryElement(collection, isEmail, entity) %} {% import '@OroUI/macros.html.twig' as ui %} {% import '@OroEmail/macros.html.twig' as email %} {% set primaryElement = null %} {% set elements = [] %} {% for element in collection %} {% if element.primary %} {% set primaryElement = element %} {% else %} {% set elements = elements|merge([element]) %} {% endif %} {% endfor %} {% if primaryElement %} {% set elements = [primaryElement]|merge(elements) %} {% endif %}