Weird behaviour when customising views-view-unformatted.html.twig with grouping I'm trying to override the views-view-unformatted.html.twig template by an unformatted view that includes a hidden Grouping field.

The default template includes this code:

{% if title %}
  &lt;h3 class="group-title"&gt;{{ title }}&lt;/h3&gt;
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  &lt;div{{ row.attributes.addClass(row_classes) }}&gt;
    {{- row.content -}}
  &lt;/div&gt;
{% endfor %}


When I copy the default template into my theme, this generates the results I would expect:



When I try to modify the code by wrapping a div around the loop that fetches the rows, like this:

{% if title %}
  &lt;h3 class="group-title"&gt;{{ title }}&lt;/h3&gt;
{% endif %}
&lt;div class="group-content"&gt;
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  &lt;div{{ row.attributes.addClass(row_classes) }}&gt;
    {{- row.content -}}
  &lt;/div&gt;
{% endfor %}
&lt;/div&gt;


I get this output instead:



Note that the first two rows are wrapped in the group-content div, whilst the third row is now wrapped in a separate group-content div. There should obviously be only one group-content div, with all rows inside it.

My goal in overriding the default template is to put them all in a separate div, which I can't do from within the views settings, so the fact that overriding the template isn't working defeats the object of the exercise.

Any ideas why this is happening, and how to get around it?
count opening and closing tag div