<p>Yes, you can do the same in Craft using Twig's <a href="http://twig.sensiolabs.org/doc/functions/cycle.html" rel="nofollow">cycle function</a>:</p>

<pre><code>{% set myClasses = ['classOne', 'classTwo', 'classThree'] %}

{% for entry in entries %}
    {{ cycle(myClasses, loop.index0) }}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-01-21T17:47:49.697Z
2015-01-21T17:53:39.307Z
2015-01-21T17:53:39.307Z
carlcs
<p>From the documentation site</p>

<pre><code>{% switch matrixBlock.type %}

    {% case "text" %}

        {{ matrixBlock.textField | markdown }}

    {% case "image" %}

        {{ matrixBlock.image[0].getImg() }}

    {% default %}

        &lt;p&gt;A font walks into a bar.&lt;/p&gt;
        &lt;p&gt;The bartender says, “Hey, we don’t serve your type in here!”&lt;/p&gt;

{% endswitch %}
</code></pre>

<p><a href="http://buildwithcraft.com/docs/templating/switch" rel="nofollow">http://buildwithcraft.com/docs/templating/switch</a></p>

CC BY-SA 3.0
2015-01-21T17:50:14.603Z
Despite the fact that the names are the same, those two functions do very different things. To be fair, EE is grossly misusing the `switch` terminology.
Lindsey D
CC BY-SA 3.0
2015-01-21T17:32:59.237Z
2015-01-21T17:32:59.237Z
magicspon
<p>Does Craft have an answer to ExpressionEngine's <code>{switch}</code> tag?</p>

<pre><code>{switch="classOne|classTwo|classThree"}
</code></pre>

<templating>
Craft's answer to {switch} from EE
# Craft's answer to {switch} from EE

(Asked by: username_0 on 2015-01-21)

Does Craft have an answer to ExpressionEngine's {switch} tag?
{switch="classOne|classTwo|classThree"}

**Tags:** templating

---

## 2 answers

### Answer by username_1 on 2015-01-21. Score: 5 | Accepted answer

Yes, you can do the same in Craft using Twig's cycle function:
{% set myClasses = ['classOne', 'classTwo', 'classThree'] %}

{% for entry in entries %}
    {{ cycle(myClasses, loop.index0) }}
{% endfor %}


---

### Answer by username_2 on 2015-01-21. Score: 0

From the documentation site
{% switch matrixBlock.type %}

    {% case "text" %}

        {{ matrixBlock.textField | markdown }}

    {% case "image" %}

        {{ matrixBlock.image[0].getImg() }}

    {% default %}

        A font walks into a bar.
        The bartender says, “Hey, we don’t serve your type in here!”

{% endswitch %}

http://buildwithcraft.com/docs/templating/switch

> **Comments:**
> **username_3**: Despite the fact that the names are the same, those two functions do very different things. To be fair, EE is grossly misusing the `switch` terminology.  

---

