{% set compare_view_title = view_title|striptags|trim %}
{% set compare_view_caption = view_caption|first|striptags|trim %}

<table{{ attributes.addClass('view__table') }}>
  {% if
    view_caption_needed and (
      (view_caption and (compare_view_caption != compare_view_title)) or
      view_summary_element is not empty
    )
  %}
    <caption class="view__caption">
      {% if caption and (compare_view_caption != compare_view_title) %}
        {{ caption }}
      {% endif %}

      {% if (view_summary_element is not empty) %}
        {{ view_summary_element }}
      {% endif %}
    </caption>
  {% else %}
    {% if view_title %}
      <h2 class="view__heading">{{ view_title }}</h2>
    {% endif %}
  {% endif %}

  {% if view_header %}
    <thead>
      <tr>
        {% for key, column in view_header %}
          <th{{ column.attributes.setAttribute('scope', 'col') }}>
            {%- if column.url -%}
              <a href="{{ column.url }}" title="{{ column.title }}" rel="nofollow">{{ column.content }}{{ column.sort_indicator }}</a>
            {%- else -%}
              {{- column.content }}
            {%- endif -%}
          </th>
        {% endfor %}
      </tr>
    </thead>
  {% endif %}

  <tbody>
    {% for row in view_rows %}
      <tr{{ row.attributes }}>
        {% for key, column in row.columns %}
          <td{{ column.attributes.setAttribute('data-cell', view_header[key].content) }}>
            {% for content in column.content %}
              {{- content.separator }}{{ content.field_output -}}
            {% endfor %}
          </td>
        {% endfor %}
      </tr>
    {% endfor %}
  </tbody>
</table>
