Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If statement ignoring parenthesis #215

Open
Nixon-Joseph opened this issue Apr 18, 2024 · 0 comments
Open

If statement ignoring parenthesis #215

Nixon-Joseph opened this issue Apr 18, 2024 · 0 comments

Comments

@Nixon-Joseph
Copy link

I had the following if statement:

{% if (model.Friends.size == nil or model.Friends.size <= 0) and (model.PendingFriends == nil or model.PendingFriends.size <= 0) %}
    <div>
        <h2 class="text-muted">#No Friends</h2>
        <p class="text-muted">You have no friends on this platform yet. Don't worry, I'm sure you'll make some!</p>
    </div>
{% endif %}

And this was ALWAYS showing the result, because PendingFriends was always an empty array, even though Friends wasn't empty.

Checking for either case individually worked as expected, but putting together a couple of grouped ORs with an AND via parenthesis did not work as expected.

PHP: 8.x
Liquid: 1.4.42
OS: Linux -> LAMP stack

If I'm just missing something, let me know, but removing the nil checks makes it work as expected (just less safe).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant