<h3>As of <a href="https://craftcms.com/changelog#build2771" rel="noreferrer">Craft 2.6</a>, this is now possible!</h3>
<p>In fact, it works exactly like your first example:</p>
<pre><code>{% case &quot;A&quot; or &quot;B&quot; or &quot;C&quot; %}
  {# run this if case matches A or B or C #}
</code></pre>
<hr />
<h3>Original answer...</h3>
<p><s><strong>Your first example</strong> is not currently possible, but might make for a good <a href="http://feedback.buildwithcraft.com/" rel="noreferrer">feature request</a>.</s></p>
<p><strong>Your second example</strong> is not possible, and most likely never will be. If it were added in the future, that would likely have a major (breaking) impact on all existing uses of the <code>switch</code> statement.</p>
<p>The way that Craft has implemented the <code>case</code> statement is by making it completely unnecessary to supply a <code>break</code> statement. In fact, the <code>break</code> statement doesn't even exist natively (though can be added with the <a href="https://github.com/marionnewlevant/craft-mnbreakandcontinue/" rel="noreferrer">MN Break and Continue</a> plugin). The <code>case</code> statement will automatically end when it hits the next <code>case</code> statement, or the <code>endswitch</code> statement.</p>
<p><strong>An actual solution</strong> would be to use a <a href="http://twig.sensiolabs.org/doc/tags/macro.html" rel="noreferrer">macro</a> or <a href="http://twig.sensiolabs.org/doc/tags/include.html" rel="noreferrer">include</a>. If you have multiple <code>case</code> statements which should trigger the same behavior, I'd recommend wrapping that behavior into a macro/include, and calling that macro/include for each relevant <code>case</code>.</p>

CC BY-SA 3.0
2015-04-20T14:19:39.410Z
Thanks Lindsey! I wasn't aware of macros, they'll be a lot of help. And I'll go ahead and submit it as a feature request; I'm sure it'll come in handy in the future.
cballenar
CC BY-SA 3.0
2015-04-19T04:36:36.953Z
2016-04-27T16:51:19.953Z
2020-06-17T08:56:27.903Z
Lindsey D
<p>Is it possible to provide different possible values per case?</p>

<p>I've tried the following formats without success.</p>

<pre><code>{% case "A" or "B" or "C" %}
  {# run this if case matches A or B or C #}
</code></pre>

<p>I saw this done somewhere else so I thought I'd give it a shot</p>

<pre><code>{% case "A" %}
{% case "B" %}
{% case "C" %}
  {# run this if case matches A or B or C #}
</code></pre>

<p>From the documentation it doesn't seem like this would be possible but wanted to check just in case. If not, any chance we'll see this sometime in the future?</p>

CC BY-SA 3.0
2015-12-02T01:02:53.277Z
Here's the feature request page for anybody who wants to have this functionality added: http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7632651-add-or-operator-support-for-switch-statements
kmgdev
<templating><switch><case>
"A" or "B" in switch statements?
# "A" or "B" in switch statements?

(Asked by: username_0 on 2015-04-19)

Is it possible to provide different possible values per case?
I've tried the following formats without success.
{% case "A" or "B" or "C" %}
  {# run this if case matches A or B or C #}

I saw this done somewhere else so I thought I'd give it a shot
{% case "A" %}
{% case "B" %}
{% case "C" %}
  {# run this if case matches A or B or C #}

From the documentation it doesn't seem like this would be possible but wanted to check just in case. If not, any chance we'll see this sometime in the future?

**Tags:** templating, switch, case
> **Comments:**
> **username_1**: Here's the feature request page for anybody who wants to have this functionality added: http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7632651-add-or-operator-support-for-switch-statements  

---

## 1 answers

### Answer by username_2 on 2015-04-19. Score: 15 | Accepted answer

As of Craft 2.6, this is now possible!
In fact, it works exactly like your first example:
{% case "A" or "B" or "C" %}
  {# run this if case matches A or B or C #}


Original answer...
Your first example is not currently possible, but might make for a good feature request.
Your second example is not possible, and most likely never will be. If it were added in the future, that would likely have a major (breaking) impact on all existing uses of the switch statement.
The way that Craft has implemented the case statement is by making it completely unnecessary to supply a break statement. In fact, the break statement doesn't even exist natively (though can be added with the MN Break and Continue plugin). The case statement will automatically end when it hits the next case statement, or the endswitch statement.
An actual solution would be to use a macro or include. If you have multiple case statements which should trigger the same behavior, I'd recommend wrapping that behavior into a macro/include, and calling that macro/include for each relevant case.

> **Comments:**
> **username_0**: Thanks Lindsey! I wasn't aware of macros, they'll be a lot of help. And I'll go ahead and submit it as a feature request; I'm sure it'll come in handy in the future.  

---

