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 over a week ago

Below is a growing, non exhaustive list of custom (fancy) mutations available to you when building custom TRMNL plugins, which are powered by the open source Liquid library.

This guide is not a resource to learn Liquid, but rather a place to gather custom filters that may be useful to TRMNL users specifically.

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 improve the rendered outcomes of your Liquid-injected data, see the "Filters" section of this cheat sheet with examples:

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 additional liquid filters:

{{ 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

{{ 10420 | number_to_currency }} # => $10.420.00

# custom currency symbol
{{ 152350.69 | number_to_currency: '£' }} # => £152,350.69

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

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 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?