Forum

Thread tagged as: Problem

OR in if statement

The OR operator in my if statement doesn't seem to be working. Here is my code

<perch:if exists="vimeo-description OR main-video-description">
  WITH DESCRIPTION
  <perch:template path="content/_project-section--with-description.html" />

  <perch:else />
  WITHOUT DESCRIPTION
  <perch:template path="content/_project-section--no-description.html" />

</perch:if>

I know for a fact that vimeo-description exists but I still get the WITHOUT DESCRIPTION version loading. The statement works if I just use vimeo-description it works, like so:

<perch:if exists="vimeo-description">
  WITH DESCRIPTION
  <perch:template path="content/_project-section--with-description.html" />

  <perch:else />
  WITHOUT DESCRIPTION
  <perch:template path="content/_project-section--no-description.html" />

</perch:if>

Is this a bug or am I doing something wrong?

Damon Golding

Damon Golding 1 points

  • 5 years ago
Simon Clay

Simon Clay 127 points

I wonder if it's to do with the fact that you've used hyphens in your IDs. Strictly speaking you should use underscores. It would be worth testing that.

Simon Clay said:

I wonder if it's to do with the fact that you've used hyphens in your IDs. Strictly speaking you should use underscores. It would be worth testing that.

Excellent catch!

Thankyou very much