Skip to content

Filters and functions

The custom filters and functions registered on the MiniJinja environment, plus built-ins you'll use.

Updated View as Markdown

The engine registers exactly four filters and one function on the MiniJinja environment (src/engine/mod.rs):

Kind Name Registered as
Filter money env.add_filter("money", money_filter)
Filter pluralize env.add_filter("pluralize", pluralize_filter)
Filter newlines_to_br env.add_filter("newlines_to_br", newlines_to_br_filter)
Filter render_text env.add_filter("render_text", render_text_filter)
Function render_node env.add_function("render_node", render_node_filter)

money

Formats an integer amount in minor units into a currency string. Optional currency argument (ISO code, default "USD").

{{ product.base_price | money }}              {# $19.99 #}
{{ 129900 | money(currency="NGN") }}          {# ₦1,299.00 #}
{{ (item.price * item.quantity) | money }}    {# math in the pipe #}

Behavior: derives the currency exponent and symbol from ringroad_constants::currency; groups thousands with commas; handles negatives. Alphabetic multi-char symbols (e.g. KSh) get a trailing space (a documented ponytail:, "KSh " renders KSh 1,299.00).

pluralize

{{ cart.item_count | pluralize(singular="item", plural="items") }}

value == 1 → singular (default "item"), else plural (default "items").

newlines_to_br

{{ node.settings.subtext | newlines_to_br }}

Replaces every \n with <br>.

render_text

Renders a merchant-entered string as a nested MiniJinja template with the current context, text settings can interpolate variables:

{{ node.settings.text | render_text }}
{# text = "Hello {{ product.name }}" → "Hello <product name>" #}

Never raises: on syntax error, missing env, or any failure the original string is returned unchanged.

render_node(child)

Renders a child node’s template inline with the current scope, wrapping the output in the standard rr-node-{id} editor wrapper. Used to render children inside loops where node.children_rendered can’t see the loop scope:

{% for child in node.children %}
  {{ render_node(child) }}
{% endfor %}
  • The theme slug is derived from the current template name.
  • The child’s node variable is replaced with the passed child.
  • Never raises: missing template or unknown type → empty string.

Built-in filters that matter

MiniJinja ships the standard Jinja2 filter set; the default theme leans on:

Filter Usage in the default theme
safe page.content_html, page_styles, header_html, settings.html_head, snippet attrs
default `hg
length `product.variants
urlencode share links (`request.path
replace / trim / lower / upper general string work
first / last / join array access

Known gaps

  • image_url is not registered. The default theme calls {{ img.src | image_url }} in navbar.jinja, product_gallery.jinja, and product_recommendations.jinja, but no such filter exists in the engine, those render paths raise an unknown-filter error today. Either the API provides ready URLs or the filter needs registering.
  • No asset_url / section / block filters exist, asset paths are hardcoded (/_assets/main.css) or come pre-resolved from data.
Navigation

Type to search…

↑↓ navigate↵ selectEsc close