Transforms¶
Normative reference
This page is a guide. The normative definition of every built-in transform — arguments, arity, and worked examples — lives in the Bars specification's Transforms reference.
An expression can be followed by zero or more pipe-separated transforms,
applied left to right: {{ name | upcase }}, {{ value | upcase | downcase }}. The pipe is the
lowest-precedence operator in the whole expression chain — in {{ a == b | upcase }}, the transform
applies to the boolean result of the comparison, not to b alone. Whitespace around | is
required, matching the rule for binary operators.
Every render starts with 56 built-in transforms available, covering strings, math, lists, and date-times — see the four family pages linked below for the full catalog. An application can add, override, or remove transforms beyond that built-in set; ask whoever built the application you're writing templates for if you need something the built-ins don't cover.
Arguments¶
Append : to a transform name, followed by one or more space-delimited arguments, to pass
arguments. Whitespace after : is required.
{{ message | append: "!" }}
{{ phrase | replace: "world" "Mark" }}
{{ name | append: (title | upcase) }}
An argument is one of:
- A literal — string, number, boolean, or
null. - A plain identifier, resolved against the current render context (any of the forms from Interpolation).
- A parenthesized expression chain —
(title | upcase)— evaluated in full, including its own transforms, before being passed as the argument.
Whitespace immediately inside a parenthesized argument's parentheses is optional: (title | upcase)
and ( title | upcase ) both parse to the same argument.
default:¶
One transform doesn't belong to any single family: default: value returns value when the input
is null, an empty string, or an empty list, and passes the input through unchanged otherwise.
Unlike Shopify Liquid, false and 0 are never replaced — kBars always behaves as if Liquid's
allow_false were true.