How do I cycle a class on a Matrix block? I am trying to add a class which will cycle through on every iteration of a matrix block type, here is my code:

{% for block in entry.asideNavigation %}

    {% switch block.type %}

        {% case 'textBlock' %}
            &lt;li class="aside__nav__item {{ cycle(['cs-a','cs-b'], loop.index0) }}"&gt;
                ...
            &lt;/li&gt;

        {% case 'imageBlock' %}
            ...

    {% endswitch %}

{% endfor %}


This cycle function gives me the error "Variable "loop" does not exist" where am I going wrong?
This is mostly likely a scoping issue inside the switch statement.  Try something like this:

{% for block in entry.asideNavigation %}

    {% set index0 = loop.index0 %}

    {% switch block.type %}

        {% case 'textBlock' %}
            &lt;li class="aside__nav__item {{ cycle(['cs-a','cs-b'], index0) }}"&gt;
                ...
            &lt;/li&gt;

        {% case 'imageBlock' %}
            ...

    {% endswitch %}

{% endfor %}