Opening and closing table within a switch Within my matrix I have two blocks: Day and Event. Day is just a date field while the event block has two text fields.

What's the best way to wrap the event data, which needs to show up as a table format within this loop?

This currently spills everything out in the correct order but the table doesn't open and close correctly around the event block.

The final output should look something like

Title (h2)

Table open
TR
TR
TR
Table close

{% for block in entry.scheduleMatrix %}

{% switch block.type %}

{% case 'day' %}
            &lt;h2&gt;{{ block.day.format('l - F j, Y') }} &lt;/h2&gt;
&lt;table&gt;&lt;tbody&gt;

{% case 'event' %}
            &lt;tr&gt;&lt;td&gt;{{ block.eventTime }}&lt;/td&gt;
            &lt;td&gt;{{ block.eventName }}&lt;/td&gt;&lt;/tr&gt;

{% endswitch %}
        &lt;/tbody&gt;
&lt;/table&gt;
{% endfor %}
I think the opening and closing tags in the table are in the wrong spot. Try opening and closing the table inside the event case.

{% for block in entry.scheduleMatrix %}

{% switch block.type %}

{% case 'day' %}
    &lt;h2&gt;{{ block.day.format('l - F j, Y') }} &lt;/h2&gt;    
{% case 'event' %}
    &lt;table&gt;
        &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;{{ block.eventTime }}&lt;/td&gt;
            &lt;td&gt;{{ block.eventName }}&lt;/td&gt;&lt;/tr&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;    
{% endswitch %}

{% endfor %}