{% 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_pro(index, count) -%} {% if count >= index %} {% if count != index %} {% endif %} {% if count == index %} {% endif %} {% if count > 1 %} {% endif %} {{index}} {% else %} {% endif %} {%- endmacro %} {% macro cell_con(index, count) -%} {% if count >= index %} {% if count != index %} {% endif %} {% if count == index %} {% endif %} {% if count > 1 %} {% endif %} {{index}} {% else %} {% endif %} {%- endmacro %} {% macro row(index, count_pros, count_cons) -%} {{ cell_pro(index, count_pros)}} {{ cell_con(index, count_cons)}} {%- endmacro %} Pros Cons {% for i in range(nb_rows) %} {{ row(i + 1, ns.pros, ns.cons) }} {% endfor %}