mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Add additional documentation
Includes descriptions of logical operator order, `else` in a `for` loop, `sort`'s parameter, and dot notation for `first`/`last`/`size`.
This commit is contained in:
@@ -87,3 +87,28 @@ You can use multiple operators in a tag:
|
||||
```
|
||||
|
||||
`contains` can only search strings. You cannot use it to check for an object in an array of objects.
|
||||
|
||||
## Order of operations
|
||||
|
||||
In tags with more than one `and` or `or` operator, operators are checked in order *from right to left*. You cannot change the order of operations using parentheses — parentheses are invalid characters in Liquid and will prevent your tags from working.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if true or false and false %}
|
||||
This evaluates to true, since the 'and' condition is checked first.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if true and false and false or true %}
|
||||
This evaluates to false, since the tags are checked like this:
|
||||
|
||||
true and (false and (false or true))
|
||||
true and (false and true)
|
||||
true and false
|
||||
false
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user