Skip to main content
Operators are used in the template language to access values, calculate values, compare content, or combine conditions. They are a fundamental part of many template expressions, for example in outputs, conditions, or when working with lists and maps. Unlike functions, operators are not written as a call with parentheses but are used directly within an expression. The existing operators reference covers access, mathematical, comparison, logical, and the containment operator in in particular.

Basics

Notation

Operators are used directly within an expression. They can occur in an output as well as in a variable assignment or a condition. To output the result of an expression directly in the template, the output notation is used:
An expression can also first be assigned to its own variable to be reused later:
The existing reference pages already show exactly this pattern for function calls, variables, and operator expressions.

Operators in outputs and conditions

Operators are particularly often used in these situations:
  • when accessing values in maps or lists
  • in calculations
  • in comparisons in if conditions
  • when linking multiple conditions
  • when checking whether a value is contained in a list or map
Examples:
The operators page already documents . and [] for access, mathematical operators, comparison operators, logical operators, and in.

Order and parentheses

As soon as multiple operators are combined in an expression, parentheses should be used to make the desired order unambiguous. This not only increases readability but also prevents misunderstandings in more complex conditions. Example: {{= ($myPrice > 0 and $stock > 0) or $myIsBackorderAllowed }} Recommendation:
  • Simple expressions can be written directly.
  • For mixed comparisons and logical connections, parentheses should be used.
  • Especially with and, or, and not, a clear structure is important.

List of operators

Dot operator .

The dot operator is used to access an attribute of a map. The existing operators page describes the dot operator as standard access to attributes of an object and also shows that it does not work with list indices. Usage example
Typical examples are accessing product data, customer data, or other structured values.
Notation
Example – output product name
Example – output shipping country from an order address
Note: the dot operator is not suitable for numeric list indices. Example – does not work with a list
Output

Index operator []

The index operator is used to access values in lists or maps. With maps, the key is specified in square brackets. With lists, the numeric index is used. According to the existing documentation, a variable can also be used in the index operator. Usage example
Useful for dynamic keys or for accessing a specific list element.
Notation
Example – access a field in a map
Example – output the first element of a list
Output
Example – use a dynamic key
Note: list indices start at 0.

Addition operator +

The operator + is used to add numeric values. The current functions page additionally documents that + can also be used to concatenate strings as well as merge lists. This contradicts the older operators page; this draft therefore follows the newer functions page. Usage example
Can be used for calculations, but also for composing texts or merging lists.
Notation
Example – add two numbers
Output
Example – compose article number from prefix and ID
Output
Example – insert number into text
Example – merge two lists
Note: when concatenating texts, non-string values may need to be converted to a string first using str().

Subtraction operator -

The operator - subtracts one value from another. The operators page documents - as one of the basic mathematical operators. Usage example
Useful for price differences, discounts, or remaining quantities.
Notation
Example – calculate price reduction
Output
Example – calculate remaining stock after deduction
Output

Multiplication operator *

The operator * multiplies two numeric values. It is part of the mathematical operators documented on the operators page. Usage example
Typical for quantity and price calculations.
Notation
Example – calculate subtotal
Example – calculate packaging units
Output

Division operator /

The operator / divides one numeric value by another numeric value. This operator is also documented in the existing math overview. Usage example
Helpful for averages, ratios, or conversions.
Notation
Example – calculate average price
Output
Example – calculate a partial quantity
Output
Note
For divisions, you should ensure that the divisor is not 0.

Modulo operator %

The modulo operator % returns the remainder of a division. The operators page expressly names % as the modulo operator. Usage example
Useful for checking even and odd values or implementing grid logic in lists.
Notation
Example – check whether a number is even
Output
Example – mark every third element in a list

Equality operator ==

The operator == checks whether two values are equal. According to the existing reference, comparison operators always return a boolean value, i.e., true or false. Usage example
Can be used for status checks, country checks, or template logic.
Notation
Example – check country
Example – compare price with maximum value
Output

Inequality operator !=

The operator != checks whether two values are unequal. It also belongs to the comparison operators documented on the operators page. Usage example
Useful when a value explicitly must not correspond to a certain state.
Notation
Example – only display when a customer is not blocked

Less than <

The operator < checks whether the left value is less than the right value. According to the current operators page, comparison operators are intended for such value comparisons. Example – check price limit

Greater than >

The operator > checks whether the left value is greater than the right value. Example – check minimum order value

Less than or equal <=

The operator <= checks whether a value is less than or equal to another value. Example – check stock

Greater than or equal >=

The operator >= checks whether a value is greater than or equal to another value. Example – check minimum age or threshold

Logical and

The operator and links two conditions. The result is only true if both conditions are met. Exactly this behavior is described with examples on the operators page. Usage example
Useful when multiple prerequisites must be met at the same time.
Notation
Example – only display the product if the price is valid and stock is available
Example – buy button only for active products with stock

Logical or

The operator or links two conditions. The result is true if at least one of the conditions is met. According to the existing reference, or belongs to the logical operators. Usage example
Suitable for alternative approvals or special cases.
Notation
Example – display the product if stock is available or pre-order is allowed

Logical not

The operator not reverses the truth value of an expression. not is also part of the logical operators documented on the operators page. Usage example
Helpful when checking that a condition is not met.
Notation
Example – only display when the user is not logged in
Example – display a message when no stock is available

Containment operator in

The operator in checks whether the left value is contained in the right object. The existing operators page expressly documents in as a containment operator and shows 1 in [1, 2, 3] as an example. Usage example
Useful for country lists, allowed values, color selections, or whitelists.
Notation
Example – check whether a color is available
Output
Example – check country against allowed country list