How Can I Include a Conditional for First Type of Matrix I want to include a conditional for when the 'Text' block type is returned for the first time in a loop. In css it would be first-of-type.

Here's what I have at the moment:

{% if type == 'text' and loop.first %}
    &lt;div class="centered spacer-icon m-all t-all d-all"&gt;&lt;img src="resources/img/minus-icon.svg" alt="Minus Icon" width="30" /&gt;&lt;/div&gt;
{% endif %}


In this instance my text block type is loop index 3 but I want to adjust the conditional because it is the first text type in the matrix field.
You could first set a variable to test against and then change it the first time the block type appears.

{% set firstTime = true %}

{% for block in entry.matrixField %}

    {% if block.type == "text" and firstTime == true %}

        ...Do something once...

        {% set firstTime = false %}

    {% endif %}

{% endfor %}