Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-31T00:33:13.997Z
Answers.Text: Ah thanks for the "They must be lowercase" note. I wondered why I couldn't get such a simple bit of logic working :)
Answers.UserDisplayName: JamesNZ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-04T00:00:09.547Z
Answers.LastActivityDate: 2014-10-04T15:55:20.940Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Lindsey D
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-05T19:08:33.567Z
Comments.Text: Thanks, all!  I had originally tried "AND" but it did not work.  Does in lowercase!!
Comments.UserDisplayName: Roi Agneta
Tags: <templating>
Title: Multiple conditions in an if statement?
ThreadText: # 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](https://craftcms.stackexchange.com/q/2882/45), 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 :)  
  
  ---
  
  