{% import "macros/styles.html.twig" as s %}
{% set piece = [] %}
{% for row in data %}
{% set index = loop.index %}
{% for group in groups %}
{% if index == 1 or data[index - 1][group] != data[index - 2][group] %}
{% include 'print/header' ~ loop.index ~ '.html.twig' %}
{% endif %}
{% endfor %}
{% set piece = piece|merge([row]) %}
{% for group in groups %}
{% if data|length == index or data[index - 1][group] != data[index][group] %}
{{ s.table(piece, cols) }}
{% include 'print/footer' ~ loop.index ~ '.html.twig' %}
{% endif %}
{% endfor %}
{% endfor %}