Skip to main content
2 of 3
added 109 characters in body

Hello, Now I made a template include matrix field.I want some html tags with the number of loops followed by block type

{% for block in entry.matrixField.all() %}
    {% switch block.type %}
        {% case 'blockType1' %}
        <div>
            {{ block.field }}
        </div>
        {% case 'blockType2' %}
        <div>
            {{ block.field }}
        </div>
        {% case 'blockType3' %}
        <ul>
            <li>
                {{ block.field }}
            </li>
        </ul>
    {% endswitch %}
{% endfor %}

Now output code within

<ul>
    <li>blockfield</li>
</ul>
<ul>
    <li>blockfield</li>
</ul>
<ul>
    <li>blockfield</li>
</ul>

But I want output like this:

<ul>
    <li>blockfield</li>
    <li>blockfield</li>
    <li>blockfield</li>
</ul>

That is, I want 'ul' tag to follow the loop of blocktype3.