Filters are used to transform a variable before outputting it. You can attach one or many filters to a variable, and you can add your own filters to augment the ones built-in to Dust.

Using Filters

Filters are attached to a Dust reference by adding a pipe | and the filter name after the reference name. You can chain filters by adding multiple pipes. The filters will be run from left-to-right.

{title}{~n} {title|s}{~n} {title|js|s} { "title": '"All is <Fair> in Love & War"' }

Built-In Filters

Dust applies the h filter to all references by default, ensuring that variables are HTML-escaped. You can undo this autoescaping by appending the s filter.

Creating a new filter

See the filter API.

Fork me on GitHub