Render the blocks in a specific order?

in the resulting html my-div1 should appear to my-div2
but he may also not appear if in the process some complex logic will be assigned to {% set flag = false %}

how this can be achieved prompt

{% set flag = false %}

{% if flag %}
 <div class="“my-div1”">
 bla bla bla
</div>
{% endif %} 

{% for a in arr %}
 .... a lot of complex heavy logic
 <div class="“my-div2”"></div>
 {% set flag = true %}
{% endfor %}
June 10th 19 at 15:32
0 answer

Find more questions by tags Twig