Skip to main content
All CollectionsPlugins
Custom plugin filters
Custom plugin filters

Improve content formatting with Liquid and localizations.

TRMNL Team avatar
Written by TRMNL Team
Updated this week

Below is a growing list of custom (fancy) mutations available to Private Plugins, whose variable interpolation is powered by the open source Liquid library.

Getting started with Liquid

To get started quickly with {{ liquid }} flavor variable notation, create a Private Plugin inside TRMNL, visit the Markup Editor, then copy/paste examples from these unofficial docs: https://shopify.github.io/liquid/

To understand how Liquid words under the hood, check out the official docs:

To parse and re-format Liquid-injected data, see the "Filters" section of this cheat sheet:

TRMNL custom filters

Given our web application is built in Ruby/Rails, we're able to extend the default Liquid library with custom filters using the following strategy:

We currently offer the following extensions:

{{ 1234 | number_with_delimiter }}  # => 1,234

# custom delimiter (default is comma)
{{ 1234 | number_with_delimiter: '.' }} # => 1.234
{{ 1000000 | number_with_delimiter: ' ' }} # => 1 000 000

# optional 2nd arg separates whole number from fractional value
{{ 1234.57 | number_with_delimiter: ' ', ',' }} # => 1 234,57

# currency handling
{{ 10420 | number_to_currency }} # => $10,420.00
{{ 152350.69 | number_to_currency: '£' }} # => £152,350.69

# optional 2nd + 3rd args delimit + separate
{{ 1234.57 | number_to_currency: '£', '.', ',' }} # => £1.234,57

# pluralize + inflect/humanize
{{ "book" | pluralize: 1 }} # => 1 book
{{ "book" | pluralize: 2 }} # => 2 books
{{ "octopus" | pluralize: 3 }} # => 3 octopi
{{ "person" | pluralize: 4 }} # => 4 people

# convert a variable to JSON
{{ my_var | json }} => {"foo":"bar"}

Note: named parameters are not supported by the Liquid library, so you must supply all preceding arguments in the case that you want to override a 2nd+ parameter default.

TRMNL also offers localization filters.

First, l_date localizes a date (object or string) to a friendlier format with strftime syntax.

{{ '2025-01-11' | l_date: '%y %b' }} # => 25 Jan

# with a specific locale, ex: Korean
{{ '2025-01-11' | l_date: '%y %b', 'ko' }} # => 25 1월

# with the user's locale; good for published Plugin Recipes
{{ '2025-01-11' | l_date: '%y %b', trmnl.user.locale }} # => 25 1월

Next, l_word translates common words to another language. Contribute more here.

<p>{{ "today" | l_word: 'es-ES' }}</p> # => hoy

{% assign day = "tomorrow" %}
<p>{{ day | l_word: trmnl.user.locale }}</p> # => 내일

Troubleshooting

Combining filters with our Framework handlers, for example Value Formatting, may produce unexpected results. For example:

<span class="value value--xlarge value--tnums" data-value-type="number">
{{ 10420.00 | number_to_currency }}
</span>

Will yield $10,420 without .00 trailing decimal places, because value--tnums attempts to simplify whole numbers.

Adding more custom filters

Email team@usetrmnl.com or hop inside our Developer-only Discord > #Plugins channel to request additional filters or arguments.

Did this answer your question?