{#
/**
 * @file
 * Theme override for displaying a view as a table.
 */
#}

{# Check if table has any real content #}
{% set has_content = false %}
{% for row in rows %}
  {% for key, column in row.columns %}
    {% set rendered = column.content|render|striptags|trim %}
    {% if rendered is not empty %}
      {% set has_content = true %}
    {% endif %}
  {% endfor %}
{% endfor %}

{% if caption_needed %}
  <tbody>
  <tr class="table-election-areas__area"><th colspan="3" scope="rowgroup">{{ caption }}</th></tr>
  {% if has_content %}
    {% for row in rows %}
      <tr{{ row.attributes }}>
        {% for key, column in row.columns %}
          <td{{ column.attributes }}{% if not loop.first %} data-label="{{ header[key].content|render|striptags|trim }}"{% endif %}>{{ column.content }}</td>
        {% endfor %}
      </tr>
    {% endfor %}
  {% else %}
    <tr><td colspan="{{ header|length }}"><em>Results pending.</em></td></tr>
  {% endif %}
  </tbody>
{% endif %}
