-
-
Notifications
You must be signed in to change notification settings - Fork 256
Description
Hey there,
I wanted to request a new feature that would solve a lot of issues when using Liquid. The possibility to add support for the Not operator (and maybe parenthesis, but let's just tackle not first). The usual response to this request is: just use the unless tag
But this is very often not enough or leads to other issues.
Here's an example:
My condition is a simple one (I don't feel like this is an edge case at all):
link && !button
The ideal code would be:
{% if link and not button %}
<a href="{{ link }}">Lot more code here</a>
{% else %}
<div>Lot more code here</div>
{% endif %}
But that doesn't work and to do it with a combination of if/unless, the code becomes:
{% if link %}
{% unless button %}
<a href="{{ link }}">Lot more code here</a>
{% else %}
<div>Lot more code here</div>
{% endunless %}
{% else %}
<div>Lot more code here</div>
{% endif %}
As you notice the issue is that [Lot more code] here becomes redundant which is pretty annoying considering that adding this simple and obvious feature would solve all these cases.
This issue is not new, a lot of people have been requesting it in the past 11 years now:
Shopify/liquid#138
If the issue is that it's a breaking change, my argument would be that it's not. It's a new feature, past code would still work totally fine and new code would have access to this feature.
It could also be optionally enabled behind an option.