Forum

Thread tagged as: Question, Runway, Shop

Else conditional needs to be closed?

Hello

Testing a simple

<perch:if exists="image"> do this <perch:else> do this instead </perch:if>

Doesn't seem to work. The else needs to be

<perch:else />

in order to work. Is it me or that needs to be in the documentation? Also didn't an update mention something about closing tags being removed?

Lexi McGee

Lexi McGee 3 points

  • 3 years ago

Else has always been a self closing tag in Perch.

https://docs.grabaperch.com/templates/conditionals/else/

<perch:if exists="name"> <h2><perch:content id="name" type="text" label="Name"></h2> <perch:else> Author unknown </perch:if>

Self closing as in it closes without a /?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Lexi,

A self-closing tag looks like this: <perch:else/>

in order to work. Is it me or that needs to be in the documentation? Also didn't an update mention something about closing tags being removed?

The example in the documentation is correct. You don't have to use a self-closing tag for perch:else if you are using the latest version of Perch.

What version are you using?

Oh my bad. Yeah 3.0.5. A bit behind. Thanks.