PlumeKit Documentation

Filters

Filters transform a value before it is printed or compared. Chain them with |:

PLUME
{post.title | default("Untitled") | upcase}
{tags | sort | join(", ")}

This page lists every built-in filter. Unknown filter names are reported as template errors, with a suggestion when the name is close to a real one.

Strings

FilterWhat it does
append(value)Adds text to the end
prepend(value)Adds text to the start
capitalizeUppercases the first character
upcaseUppercases the whole string
downcaseLowercases the whole string
replace(target, replacement)Replaces every occurrence
replaceFirst(target, replacement)Replaces the first occurrence
remove(value)Deletes every occurrence
removeFirst(value)Deletes the first occurrence
split(separator)Turns a string into an array
slice(start, length)Takes part of a string or array; negative starts count from the end
truncate(length, omission)Shortens to a character length; the omission defaults to ...
truncateWords(count)Shortens to a word count with an ellipsis
stripTrims whitespace from both ends
lstripTrims leading whitespace
rstripTrims trailing whitespace
stripNewlinesRemoves newline characters
stripHTMLRemoves HTML tags
newlineToBRTurns newlines into <br> tags
slugifyLowercases and hyphenates for URLs
urlEncodePercent-encodes for use in URLs
urlDecodeDecodes percent-encoding

Arrays

FilterWhat it does
firstThe first item
lastThe last item
sizeThe number of items, or the length of a string
map(field)Collects one field from each item
where(field, value)Keeps items whose field matches
sort(field)Sorts by a field, or by value without one
sortNatural(field)Case-insensitive, human-friendly sort
reverseReverses the order
uniqueDrops duplicate values
compactDrops nil values
concat(values)Appends another array
join(separator)Combines items into a string

Numbers

FilterWhat it does
plus(value)Addition
minus(value)Subtraction
times(value)Multiplication
dividedBy(value)Division; dividing by zero returns 0
modulo(value)Remainder
round(precision)Rounds, optionally to a number of decimal places
absAbsolute value
ceilRounds up
floorRounds down
atLeast(value)Clamps up to a minimum
atMost(value)Clamps down to a maximum

Dates

Date filters accept ISO 8601 strings and Unix timestamps.

FilterWhat it does
date(format)Formats with an ICU pattern such as "d MMMM yyyy", or Liquid-style % patterns
dateToStringA short standard date
dateToLongStringA longer standard date
dateToXMLSchemaISO 8601, useful for <time datetime> and JSON Feed
dateToRFC822RFC 822, useful for RSS

Output

FilterWhat it does
default(value)Substitutes when the value is missing, an empty string, an empty array or false; the number 0 is kept
jsonEncodes the value as JSON
escapeHTML-escapes a string
escape_onceHTML-escapes without double-escaping existing entities
rawMarks trusted content as safe HTML

Use raw sparingly; see Syntax for how escaping works.