Files
liquidjs/docs/source/tutorials/operators.md
T
ed15a52c26 docs: revisit wording & style for liquidjs.com (#906)
* docs: polish theme, playground, and reference pages

Improve readability of the docs site with updated light/dark tokens, shared
code-block styling, and playground editors that follow system color scheme.
Skip CookieHub on localhost, serve the browser bundle from theme source, and
use backtick titles on filter/tag reference pages for consistent navigation.

Co-authored-by: Cursor <[email protected]>

* docs: highlight npx in bash blocks and polish English copy

Use Prism insertBefore for CLI commands like npx, tighten tutorial and reference wording, and keep YAML titles free of backticks so sidebar and page headings stay correct.

Co-authored-by: Cursor <[email protected]>

* docs: restore lowercase filter and tag titles

Titles should match actual filter/tag identifiers (e.g. abs, append), not capitalized English labels.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
2026-06-08 00:26:52 +08:00

1.6 KiB

title
title
Operators

LiquidJS operators are very simple and different. There are 2 types of operators supported:

  • Comparison operators: ==, !=, >, <, >=, <=
  • Logical operators: not, or, and, contains

Thus arithmetic operators are not supported and you cannot add two numbers like this {% raw %}{{a + b}}{% endraw %}. Instead, use a filter: {% raw %}{{ a | plus: b}}{% endraw %}. Actually + is a valid variable name in LiquidJS.

Logical Operators

not

Negates a condition. Returns true if the condition is false, and false if the condition is true.

Input

{% if not user.active %}
  User is inactive
{% endif %}

and

Returns true if both conditions are true.

Input

{% if user.age >= 18 and user.verified %}
  Access granted
{% endif %}

or

Returns true if at least one condition is true.

Input

{% if user.isAdmin or user.isModerator %}
  You have elevated privileges
{% endif %}

contains

Checks if a string contains a substring, or if an array contains an element.

Input

{% if product.title contains "Pack" %}
  This is a pack
{% endif %}

Precedence

  1. Comparison operators, and contains. All comparison operators alongside contains have the same (highest) precedence.
  2. not operator. It has slightly more precedence than or and and.
  3. or and and operators. These logical operators have the same (lowest) precedence.

Associativity

Logical operators are evaluated from right to left, see shopify docs.