Skip to main content
Backend templates insert values with {{ path }} and can transform them with filters using the pipe character: {{ path | filter }} or {{ path | filter:arg }}. For filter:arg, the argument can be either:
  • a context path/expression (for example product.currency_code)
  • or a literal (recommended as quoted text, for example 'USD' or 'stripe')

Variables: {{ path }}

Values are resolved from the current context (e.g. page data, article, posts, featured). Paths can use dot notation and array indexing. If a value is missing, it usually renders as empty unless you use the default filter.

Filters

Filters are applied left to right. You can chain several: {{ value | filter1 | filter2:arg }}.

Filter arguments (:arg)

Use :arg when a filter needs one parameter.
In the first example, product.currency_code is resolved from context (for example, USD).
In the second example, 'USD' is a fixed literal.
If you want text to always be treated as literal, quote it.

Translation filter: t

For brand translations, | t treats the piped value as a translation key string. Resolution matches t(): brand dictionary for the resolved locale first, then built-in locale strings. Optional | t:params passes a context variable or safe expression that resolves to a plain object for built-in placeholder interpolation (same rules as t(key, params)).
Use t() and | t in templates for the same resolution order (brand first, then built-in). See Internationalization (i18n) for locales(), {{ locale }}, and backend await t().

Fallback filters

default — fallback when value is empty

If the value is empty (null, undefined, or empty string), the filter returns the argument instead.
Chain multiple fallbacks — the first non-empty value wins.

default_if_none — fallback only for null/undefined

Like default, but only triggers when the value is null or undefined. An empty string passes through unchanged.

String filters

upper / lower / capitalize / title

trim

Strip leading and trailing whitespace.

first / last

Return the first or last character of a string (or first/last element of an array).

slice — substring

Use slice:start:end (e.g. slice:0:1 for the first character, slice:0:3 for the first 3).
Parentheses ensure the whole expression is evaluated first, then slice is applied to the result.

replace — find and replace

Replace all occurrences of a substring. Arg format: 'old':'new'. Plain string replacement — no regex.

truncate — limit character length

Truncate to N characters, appending ... if the value was cut.

truncatewords — limit word count

Truncate to N words, appending ... if cut.

nl2br — newlines to <br>

Convert newline characters to <br> tags. The value is HTML-escaped first, so user content is safe. Chain with | raw to render the output as HTML.

strip_tags — remove HTML tags

Strip all HTML tags from a string. Useful for getting plain text from rich content.

url_encode — percent-encode for URLs

Encode a value for safe use in a URL query string.

length / size

Return the number of characters in a string, or the number of elements in an array. size is an alias.

Number filters

round

Round to the nearest integer, or to N decimal places.

floor / ceil

Round down or up to the nearest integer.

abs

Absolute value.

number_format

Format a number with thousands separator and fixed decimal places (default 2).

currency

Format a number as currency. Optional arg is the ISO 4217 currency code (default USD).

Boolean / conditional filters

yesno

Return a string based on whether the value is truthy or falsy. Arg format: 'yes':'no' or 'yes':'no':'maybe' (the third value is used for null/undefined).

Array filters

join

Join an array into a string with a separator.

sort

Sort an array alphabetically (strings) or numerically.

reverse

Reverse a string or array.

unique

Remove duplicate values from an array.

Date filters

date — format a date

Format a Date object, timestamp (ms), or the string 'now' using format tokens.

date_add — add days to a date

Add N days to a date value. Returns a Date object — chain with | date to format.
Use a negative number to subtract days.

timeago — relative time

Render a date as a human-readable relative string.

Output / serialization filters

raw — output HTML unescaped

By default, output is HTML-escaped for safety. Use raw only for trusted HTML (e.g. stored rich content like article body or excerpt).

json — serialize to JSON

Serialize any value to a JSON string. Safe: uses JSON.stringify, no code is executed. Chain with | raw to embed the output in HTML attributes or <script> tags without double-escaping.

Patterns from real templates

Date with fallbacks:
Avatar initial when no image:
Excerpt or summary, then output as HTML:
First initial from full name:
Price formatted as currency:
Trial end date:
Multi-line user notes:
Embed data as JSON:
Optional category:

String concatenation: +

Use the + operator to join strings, variables, and filtered expressions together.
You can combine it with filters by wrapping the filtered part in parentheses:
This works everywhere expressions are accepted — in {{ }}, in @set, and in @component arguments:
Strings are literal — there is no variable interpolation inside quotes. Writing "price is: {{ price }}" outputs the text price is: {{ price }} verbatim, it does not resolve the variable. To mix text and variables, use concatenation:

Filter reference


Summary

  • Use {{ path }} to output a value; use | filter or | filter:arg to transform it.
  • Chained defaulta | default:b | default:c gives the first non-empty value.
  • slice:0:1 — First character; combine with (expression | default:'X') for safe initials.
  • raw — Use only for trusted HTML (e.g. article body, nl2br output, json).
  • Parentheses{{ (expression) | filter }} so the filter applies to the whole expression.
  • Concatenation"text" + variable + "more text" joins values. No interpolation inside strings; use + instead.
  • | t — Pipe a string key for translations; see Internationalization.
These functions generate URLs for purchase and subscription actions. Use them in link href attributes. These can also be used as filters: {{ 'old_sku' | upsell_upgrade('new_sku') }}. See Subscription Upsells for usage details and examples.
For conditionals and loops, see Directives. For client-side templates, see Frontend Template Engine.