IF and OR condition

I perused documentation section for IF and found following santax for Else if condition:

Use Else if to check multiple conditions:

<If first_condition>
  First condition is true.
<Else if second_condition />
  First condition is false.
  Second condition is true.
<Else />
  All conditions are false.
</If>

In the above condition we can use multiple conditions but the <Else> condition is displayed when first two conditions are false. What if we want either first condition is true or second condition is true then <Else> condition be displayed. Something like this:

<If first_condition>
  First condition is true.
<Or if second_condition />
if either First or Second condition is true.
</Or>
  All conditions are false.
</If>

Also: documentation page shows <Else> tag closing as <Else /> However it shows error and </Else> works fine.

That’s an interesting idea! L&L’s logic variables currently allow you to achieve this, albeit with slightly longer syntax than you’re suggesting. What the template would actually look like would depend on exactly what you’re trying to do, but to achieve the kind of logic structure you wrote in your example, it could look something like this:

<Set logic=complex_condition any=true>
  <If first_condition>true<Else />false</If>
  <If second_condition>true<Else />false</If>
</Set>

<If first_condition>
  First condition is true.
</If>

<If logic=complex_condition />
  Either First or Second condition is true.
<Else />
  All conditions are false.
</If>

The way L&L is currently set up, if you’re just evaluating a single condition and need to display one thing when the condition is true and another when the condition is false, then you can use If and Else. If you need to evaluate multiple conditions against each other using AND or OR logic, then you can use logic variables. If you need to get really crazy, you can nest a handful of logic variables. If you have any kind of situation where that syntax isn’t flexible enough, I’d be curious to hear about it in real-life terms to understand its limitations since I’m not currently able to imagine it.

Hope that’s helpful!

1 Like

Thank you this santax is enough for me.

1 Like