web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Unexpected Liquid 'or'...
Power Pages
Unanswered

Unexpected Liquid 'or' operator behavior

(0) ShareShare
ReportReport
Posted on by 12

Hi there,

 

I'm wondering if this is the intended behavior for liquid `or` operator, as this had made me spend hours to debug a thing that I was working on.

 

Basically, the behavior that I find confusing is: 

  • true or false evaluated into true, while
  • false or true evaluated into false

gwct_0-1678267400285.png

 

Categories:
I have the same question (0)
  • soundharya Profile Picture
    249 on at

    You have to use if condition 

    {% if product.type == "Shirt" or product.type == "Shoes" %}
     This is a shirt or a pair of shoes.
    {% endif %}
  • Fubar Profile Picture
    8,338 Super User 2025 Season 2 on at

    {{...}} is not the same as {%.....%} .   In your case using the {{ it may just be outputting the first word it sees inside the {{ and not actually evaluating anything.

     

    <p>{% if true or false %}true {% else %}false {% endif %} </p>
    <p>{% if false or true %} true {% else %}false {% endif %} </p>
    <p>{% if true and true %} true {% else %} false {% endif %} </p>
    <p>{% if false and true %} true {% else %} false {% endif %} </p>
    <p>{% if false and false %} true {% else %}false {% endif %} </p>
    
    Outputs
    true
    true
    true
    false
    false

     

  • gwct Profile Picture
    12 on at

    Ah okay, now that I've checked again that  {{ }} and  {% %} do behave differently.
    And I think the behavior for {{ }} is similar to what can be found in {% assign varA = ... %} where the right side of the assignment just tries to grab the whatever on the leftmost side of the operation is it?

    I found the problem first time when i was trying to store the value of some boolean operation into a variable, where the operation results ends up around {% assign varA = false or false or true %} and it ends up storing false, that's why i was confused with the behavior

  • Verified answer
    Fubar Profile Picture
    8,338 Super User 2025 Season 2 on at

    Yes, there can also be some fun stuff if it is multiple logical operators - its not really documented in the portal doco but there is a little bit more in the Shopify doco under Order of Operations https://shopify.github.io/liquid/basics/operators/ (Liquid originates from Shopify who open sourced it)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard