Formatting numbers with liquid syntax

Overview

Ortto allows you to use Liquid template language in your email, SMS, and push notifications. In addition to formatting text, Liquid also supports basic math and logical operations, making it easy to calculate values, compare numbers, and control what content is shown to contacts.

By combining merge tags with Liquid math filters and conditional logic, you can create messages that adapt automatically such as calculating totals, enforcing limits, or displaying different content based on numeric values.

Learn more about personalizing campaign content with Liquid.


Performing basic math in Liquid

Liquid includes math filters that let you perform calculations directly inside your messages and action shapes. These are useful for totals, adjustments, scaling values, or simple calculations without external logic.

Description

Format

Example Output

Notes

Add

{{ 16 | plus: 4 }}

20

Adds the second value to the first.

Subtract

{{ 4 | minus: 2 }}

2

Subtracts the second value from the first.

Multiply

{{ 3 | times: 2 }}

6

Multiplies two values.

Divide

{{ 50 | divided_by: 1.5 }}

33.33333333

Returns a decimal when the divisor is a decimal.


Rounding and number control

Liquid provides multiple ways to round numbers and keep values within a defined range. This helps prevent unexpected results and keeps values clean for display.

Description

Format

Example Output

Notes

Round

{{ 1.2 | round }}

1

Rounds to the nearest whole number or specified decimals.

Ceiling (round up)

{{ 1.8 | ceil }}

2

Always rounds up to the nearest whole number.

Floor (round down)

{{ 1.2 | floor }}

1

Always rounds down to the nearest whole number.

Maximum value

{{ 4 | at_most: 3 }}

3

Caps the value at the specified maximum.

Minimum value

{{ 4 | at_least: 5 }}

5

Raises the value to the specified minimum if needed.


Working with remainders and absolute values

Some calculations require working with remainders or ensuring values are always positive. You can use liquid filters to return these outputs.

Description

Format

Example Output

Notes

Absolute value

{{ -12.68 | abs }}

12.68

Converts a number to a non-negative value.

Modulo (remainder)

{{ 24 | modulo: 7 }}

3

Returns the remainder of a division operation.


Comparisons and conditional logic

Liquid supports conditional statements and logical operators, allowing you to compare values and display different content depending on the result.

Description

Format

Example Output

Notes

Compare three values

{% if ScoreA > ScoreB and ScoreA > ScoreC %} Score A is the largest. {% endif %}

Score A is the largest

Evaluates multiple conditions using logical operators.