{% set ns = namespace(pros=0, cons=0) %} {% for i in range(20) %} {% if uniquePathsAt(elements, 'pros-' ~ i ~ '$') | length != 0 %} {% set ns.pros = i %} {% endif %} {% if uniquePathsAt(elements, 'cons-' ~ i ~ '$') | length != 0 %} {% set ns.cons = i %} {% endif %} {% endfor %} {% set nb_rows = [ns.pros, ns.cons] | max %} {% macro cell(index, count, id) -%} {% set has = count >= index %} {% if has %} {% if index == count %} {% endif %} {% if count > 1 %} {% endif %} {% endif %} {%- endmacro %} {% macro row(index, count_pros, count_cons) -%} {{ cell(index, count_pros, 'pros')}} {{ cell(index, count_cons, 'cons')}} {%- endmacro %} Pros Cons {% for i in range(nb_rows) %} {{ row(i + 1, ns.pros, ns.cons) }} {% endfor %}