Skip to content

Filters

Filters transform values after they're resolved. They let you manipulate text, process arrays, format numbers, and much more. Filters are comma-separated and can be chained together for powerful data transformations.


String Filters

FilterSyntaxDescription
Truncatetruncate NShorten to N characters, append ...
Replacereplace "X" with "Y"Replace all occurrences of X with Y
URL Encodeurl_encodePercent-encode for use in URLs
Strip HTMLstrip_htmlRemove all HTML tags
TrimtrimRemove leading and trailing whitespace
Newline to BRnewline_to_brConvert line breaks to <br> tags
Splitsplit "sep"Split a string into an array
Truncate
Template
{the user's Bio, truncate 50}
Output
Jane is a marketing professional who specializes...
Replace
Template
{the user's Code, replace "-" with " "}
Output
ABC 123
URL Encode
Template
{the user's Email, url_encode}
Output
jane%40example.com
Strip HTML (input: <b>Bold</b> text and more)
Template
{the user's Bio, strip_html}
Output
Bold text and more
Trim (input: ' Jane Doe ')
Template
{the user's Name, trim}
Output
Jane Doe
Newline to BR
Template
{the user's Note, newline_to_br}
Output
Line one<br>Line two
Split into array
Template
{the user's Name, split " "}
Output
["Jane", "Doe"]

Array Filters

FilterSyntaxDescription
Joinjoin "sep"Join array elements with a separator
FirstfirstGet the first element
LastlastGet the last element
Lengthlength or sizeCount the number of elements
SortsortSort alphabetically (case-insensitive)
ReversereverseReverse the order
UniqueuniqueRemove duplicates (preserves order)
Wherewhere "attr" is "val"Filter list of objects by attribute value
Mapmap "attr"Extract one field from each object
Sliceslice N MGet a sub-array from index N to M
Join
Template
{the user's Tags, join ", "}
Output
vip, active, premium
First
Template
{the user's Items, first}
Output
Widget
Last
Template
{the user's Items, last}
Output
Gadget
Length
Template
{the user's Items, length}
Output
3
Sort
Template
{the user's Tags, sort}
Output
["active", "premium", "vip"]
Reverse
Template
{the user's Items, reverse}
Output
["Gadget", "Alpha", "Widget"]
Unique (removes duplicate 'vip')
Template
{the user's Tags, unique}
Output
["vip", "active"]
Where filter
Template
{the user's Orders, where "status" is "active"}
Output
[{name: "Widget", status: "active"}]
Map
Template
{the user's Orders, map "name"}
Output
["Widget", "Gadget", "Alpha"]
Slice (first 3 items)
Template
{the user's Items, slice 0 3}
Output
["Widget", "Gadget", "Alpha"]

Number Filters

FilterSyntaxDescription
Roundround NRound to N decimal places
Defaultdefault "val"Fallback on null, empty string, and zero
Round
Template
{the user's Score, round 2}
Output
3.14
Default (when value is null)
Template
{the user's Name, default "Guest"}
Output
Guest

default vs or

Warning

The default filter and the or modifier behave differently:

  • or "value" triggers only when the data is null/missing
  • default "value" triggers on null, empty string "", and zero 0

Use or when you only want to replace missing values. Use default when you also want to replace empty strings and zeros.

Scenarioor "Guest"default "Guest"
Value is nullGuestGuest
Value is "" (empty)(empty)Guest
Value is 00Guest
Value is "Jane"JaneJane

Chaining Filters

Filters apply left-to-right -- the output of each filter becomes the input for the next. This lets you build powerful transformation pipelines:

Chain: strip HTML, truncate, then trim
Template
{the user's Bio, strip_html, truncate 100, trim}
Output
Clean truncated text from a long HTML bio...
Chain: filter, extract, sort, join
Template
{the user's Orders, where "status" is "active", map "name", sort, join ", "}
Output
Alpha, Widget
Chain: split then get first
Template
{the user's Name, split " ", first}
Output
Jane
Chain: deduplicate, sort, join
Template
{the user's Tags, unique, sort, join " | "}
Output
active | premium | vip

How Chaining Works (Step by Step)

Here's how {the user's Orders, where "status" is "active", map "name", sort, join ", "} is evaluated:

  1. Resolve the user's Orders -- gets the full list of order objects
  2. where "status" is "active" -- filters to only orders with status "active"
  3. map "name" -- extracts just the name field from each order
  4. sort -- sorts the names alphabetically
  5. join ", " -- combines them into a comma-separated string
Tip

When chaining filters, think about what type of data each filter expects. Array filters like sort and join need arrays as input. String filters like truncate need strings. The split filter converts a string to an array, and join converts an array back to a string.


Complete Filter Reference

FilterSyntaxInput TypeOutput Type
truncatetruncate NStringString
replacereplace "X" with "Y"StringString
url_encodeurl_encodeStringString
strip_htmlstrip_htmlStringString
trimtrimStringString
newline_to_brnewline_to_brStringString
splitsplit "sep"StringArray
joinjoin "sep"ArrayString
firstfirstArrayAny
lastlastArrayAny
length / sizelengthArray/StringNumber
sortsortArrayArray
reversereverseArrayArray
uniqueuniqueArrayArray
wherewhere "attr" is "val"ArrayArray
mapmap "attr"ArrayArray
sliceslice N MArrayArray
roundround NNumberNumber
defaultdefault "val"AnyAny