<p>Twig doesn't accept <code>||</code> or <code>&amp;&amp;</code>... Try using <code>or</code> and <code>and</code> instead.</p>



<pre><code>{% if foo == 'x' or foo == 'y' %}
</code></pre>

<p>Important to note, <strong>they must be lowercase</strong>.</p>

<p>You may also want to take a look at <a href="https://craftcms.stackexchange.com/q/2882/45">this question</a>, which shows another way to write a similar condition:</p>

<pre><code>{% if foo in ['x', 'y'] %}
</code></pre>

CC BY-SA 3.0
2017-01-31T00:33:13.997Z
Ah thanks for the "They must be lowercase" note. I wondered why I couldn't get such a simple bit of logic working :)
JamesNZ
CC BY-SA 3.0
2014-10-04T00:00:09.547Z
2014-10-04T15:55:20.940Z
2017-04-13T12:51:00.253Z
Lindsey D
<p>Is it not possible to define multiple conditions in an if statement?  </p>

<pre><code>{% if foo == 'x' || foo == 'y' %}
</code></pre>

<p>I tried this and got an error:</p>

<blockquote>
  <p>Unexpected token "punctuation" of value "|" ("name" expected)</p>
</blockquote>

CC BY-SA 3.0
2014-10-05T19:08:33.567Z
Thanks, all!  I had originally tried "AND" but it did not work.  Does in lowercase!!
Roi Agneta
<templating>
Multiple conditions in an if statement?
# Multiple conditions in an if statement?

(Asked by: username_0 on 2014-10-03)

Is it not possible to define multiple conditions in an if statement?  
{% if foo == 'x' || foo == 'y' %}

I tried this and got an error:

Unexpected token "punctuation" of value "|" ("name" expected)

**Tags:** templating
> **Comments:**
> **username_0**: Thanks, all!  I had originally tried "AND" but it did not work.  Does in lowercase!!  

---

## 1 answers

### Answer by username_1 on 2014-10-04. Score: 21

Twig doesn't accept || or &&... Try using or and and instead.
{% if foo == 'x' or foo == 'y' %}

Important to note, they must be lowercase.
You may also want to take a look at this question, which shows another way to write a similar condition:
{% if foo in ['x', 'y'] %}

> **Comments:**
> **username_2**: Ah thanks for the "They must be lowercase" note. I wondered why I couldn't get such a simple bit of logic working :)  

---

