{# LIBRARIES #}
{{ attach_library('ui_patterns/rows_cols.rows_cols_lib') }}

{# VARIABLES #}
{% set batch = batch|default(3) %}
{% set col_width = (12 / batch) %}
{% set row_class = row_class|default("mb-4") %}
{% set col_class = col_class|default(false) %}
{% set wrapper_class = wrapper_class|default('') %}

{# TEMPLATE #}
{% if items %}
  {# we only need a wrapper if we are passing a class such as container #}
  {% if wrapper_class or auto_height %}
    <div class="{{ auto_height ? 'auto-height' }} {{ wrapper_class }}">
  {% endif %}

  {% for row in items|batch(batch) %}
    <div class="row {{ row_class }}">
      {% for item in row %}
        <div class="{{ col_class ? col_class : 'col-md-'~col_width }}">
          {{ item|raw }}
        </div>
      {% endfor %}
    </div>
  {% endfor %}
  {% if wrapper_class or auto_height %}
    </div>
  {% endif %}
{% endif %}
