# Filters

A filter is a Ruby method that takes one or more parameters and returns a value. Parameters are passed to filters by position: the first parameter is the expression that precedes the pipe character, and additional parameters can be passed using the name: arg1, arg2 syntax.

Output markup can take filters, which modify the result of the output statement. You can invoke filters by following the output statement's main expression with:

  • A pipe character (|)
  • The name of the filter
  • Optionally, a colon (:) and a comma-separated list of additional parameters to the filter. Each additional parameter must be a valid expression, and each filter predefines the parameters it accepts and the order in which they must be passed.

Filters can also be chained together by adding additional filter statements (starting with another pipe character). The output of the previous filter will be the input for the next one.

Hello {{ 'tobi' | upcase }}
Hello tobi has {{ 'tobi' | size }} letters!
Hello {{ '*tobi*' | textilize | upcase }}
Hello {{ 'now' | date: "%Y %h" }}

# Basics

# Append

Adds a string e.g. {{ 'foo' | append:'bar' }} #=> 'foobar'

# Capitalize

Capitalizes the first letter of each word in the input string.

# Ceiling

Rounds up a decimal number to the next integer, e.g. {{ 4.6 | ceil }} #=> 5

# Date

Formats a date (syntax reference (opens new window))

# Default

Returns the given variable unless it is null or empty string, then it returns the given value, e.g. {{ undefined_variable | default: "Default value" }} #=> "Default value"

# Divided by

Integer division e.g. {{ 10 | divided_by:3 }} #=> 3

# Downcase

Converts an input string to lowercase.

# Escape

HTML escapes a string.

# Escape once

Returns an escaped version of html without affecting existing escape entities.

# First

Gets the first element of the passed array.

# Floor

Rounds a decimal number down to the nearest integer, e.g. {{ 4.6 | floor }} #=> 4

# Format date

Formats a date with the site's localization, uses the same syntax as date.

# Join

Joins array elements with a certain character between them.

# Last

Gets the last element of the passed array.

# Lstrip

Removes all whitespace from the beginning of a string.

# Map

Maps/collects an array into a given property.

# Minus

Subtraction e.g. {{ 4 | minus:2 }} #=> 2

# Modulo

Modulo e.g. {{ 3 | modulo:2 }} #=> 1

# Newline to br

Replaces each newline (\n) with HTML break tag.

# Plus

Performs addition e.g. {{ '1' | plus:'1' }} #=> 2, {{ 1 | plus:1 }} #=> 2

# Prepend

Prepends a string e.g. {{ 'bar' | prepend:'foo' }} #=> 'foobar'

# Remove

Removes all occurrences e.g. {{ 'foobarfoobar' | remove:'foo' }} #=> 'barbar'

# Remove first

Removes the first occurrence e.g. {{ 'barbar' | remove_first:'bar' }} #=> 'bar'

# Replace

Replaces all occurrences e.g. {{ 'foofoo' | replace:'foo','bar' }} #=> 'barbar'

# Replace first

Replaces the first occurrence e.g. {{ 'barbar' | replace_first:'bar','foo' }} #=> 'foobar'

# Reverse

Reverses the given array.

# Round

Rounds to the nearest integer or to the specified number of decimals e.g. {{ 4.5612 | round: 2 }} #=> 4.56

# Rstrip

Removes all whitespace from the end of a string

# Script tag

Generates the HTML <script> tag for JavaScript, taking as parameters the URL and attributes of the form attr: 'value', e.g. {{ 'my-js-url' | script_tag: async: 'async', defer: 'defer' }} => <script src='my-js-url' type='text/javascript' async='async' defer='defer'></script>

# Size

Returns the size of an array or string

# Slice

Splits a string. Takes an offset and length, e.g. {{ "hello" | slice: -3, 3 }} #=> llo

# Sort

Sorts array elements

# Split

Splits a string on a matching pattern e.g. {{ "a~b" | split:"~" }} #=> ['a','b']

# Times

Multiplies e.g. {{ 5 | times:4 }} #=> 20

# Truncate

Restricts a string to x characters. Also accepts a second parameter that will be appended to the string e.g. {{ 'foobarfoobar' | truncate: 5, '.' }} #=> 'foob.'

# Truncatewords

Restricts a string to x words

# Uniq

Removes duplicate elements from an array, optionally using a given property to check for uniqueness.

# Upcase

Converts an input string to uppercase

# URL encode

URL-encodes a string

# Commerce

These are the liquid filters that alter values related to Commerce.

# Format currency

Adds currency format to a value. e.g. {{ 4 | format_currency }} => $4

{{ 1890.5123 | format_currency: unit: '¥', separator: ',', delimiter: '.', precision: 3 }} = ¥1.890,512

Important

This filter determines the currency format and takes precedence over any other currency configuration.

If you don't specify currency parameters with the currency filter, Modyo uses the realm's payment configuration.

If the site doesn't have an associated realm and you don't specify parameters, the predefined format of the site's language will be applied.

Parameters:

  • unit - currency symbol.
  • separator - decimal separator.
  • delimiter - thousands separator.
  • precision - number of decimal digits.

# Content

These are the liquid filters that alter values related to the Content module in Modyo Platform.

# Asset image

Returns the tags of an image using its uuid from the File Manager. If using Cloudflare for image optimization, you can use these additional parameters: width, height, blur, quality, format and fit. e.g. {{ uuid | asset_image: width: 40, format: 'auto', fit: 'cover' }}

Returns the URL of an image using its uuid from the File Manager. e.g. {{ uuid | asset_link: 'This is a link for the asset' }}

# Asset URL by UUID

Returns the URL of an image using its uuid from the File Manager. e.g. {{ uuid | asset_url_by_uuid }}

# Asset video

Returns the tags of a video using its uuid from the File Manager. e.g. {{ uuid | asset_video: 350, 300 }}

Parameters:

  • uuid (String) — asset uuid
  • width (Integer) (default: 300) — width
  • height (Integer) (default: 200) — height

# By category

Returns a list of Entries that belong to the selected Category. e.g. {% assign filtered_entries = entries | by_category: 'category2,category1,category3' %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • list (String) (default: '') — String with comma-separated categories.

# By lang

Returns a list of Entries that belong to a selected language. e.g. {% assign entries = widget.entries | locale: 'es,en,pt' %} => entries

Parameters:

  • entries (ArrayEntry) — array with entries
  • locale (String) (default: '') — String with comma-separated languages.

# By slug

Returns a list of Entries that belong to a selected slug. e.g. {% assign filtered_entries = entries | by_slug: 'slug2,slug1,slug' %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • slug (String) (default: '') — Comma-separated slugs.

# By tag

Returns a list of Entries that belong to a selected tag. e.g. {% assign entries = widget.entries | by_tag: 'tag2,tag1,tag3' %} => entries

Parameters:

  • entries (ArrayEntry) — array with entries
  • locale (String) (default: '') — String with comma-separated tags.

# By type

Returns a list of Entries that belong to a selected Content Type. e.g. {% assign filtered_entries = entries | by_type: 'type2,type1,type3' %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • locale (String) (default: '') — String with comma-separated content types.

# By UUID

Filters an array of entries by one or more UUIDs.

Parameters:

  • entries (ArrayEntry) — collection (object before the pipe)
  • uuid_list (String) — comma-separated list of UUIDs

Defaults: If uuid_list is blank returns the original collection.

e.g. {% assign filtered = entries | by_uuid: 'uuid2,uuid1,uuid3' %}

# Composite Entry Filter (by)

Applies multiple entry filters in one call. Supported option keys (all optional):

  • types: comma-separated type slugs (applies by_type)
  • categories: comma-separated category slugs (applies by_category)
  • tags: comma-separated tags (applies by_tag)
  • slugs: comma-separated entry slugs (applies by_slug)
  • uuids: comma-separated UUIDs (applies by_uuid)
  • locale: locale code (applies by_lang)
  • from_published_date: date string (>= published_at)
  • to_published_date: date string (<= published_at)
  • sort_by: field name (name, slug, created_at, updated_at, published_at, or a field path)
  • order: asc | desc (default: desc)
  • per_page: integer results per page (enables pagination if provided; default: 10)
  • page: integer page number (default: 1)

e.g. {% assign entries = spaces['testing'].entries | by: types: 'promo,basic', locale: 'es', categories: 'starred,favorites', tags: 'test,test2', slugs: 'slug2,slug1', uuids: 'uuid2,uuid1', sort_by: 'name', order: 'asc', per_page: 10, page: 2 %}

# Filter By

Returns a list of Entries that match a filter. e.g. {% assign entries = widget.entries | filter_by: field: 'name', eq: 'entry3Cat3' %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • opts (Hash) (default: {}) — hash with field and operator/value pairs

Supported Operators (use as keys in opts):

  • eq — equals (implicit when only field and value provided)
  • gt, lt — greater than / less than
  • in — field value must be one of the comma-separated values
  • nin — field value must NOT be one of the comma-separated values
  • has — array-type field must contain all of the comma-separated values

All multi-value operators take a comma-separated string.

Examples:

Filter entries where the status field is either 'published' or 'featured': {% assign entries = entries | filter_by: field: 'status', in: 'published,featured' %}

Filter entries where the author_id is not 1 or 5: {% assign entries = entries | filter_by: field: 'author_id', nin: '1,5' %}

Filter entries that have both 'tech' and 'news' in their categories array field: {% assign entries = entries | filter_by: field: 'categories', has: 'tech,news' %}

# Filter By Query String

Returns a list of Entries that match a query. You can use logical operators, various meta fields, URLs, or Liquid tags.

Operators:

  • gt, lt, in, all, nin

Fields:

  • meta.category meta.category_slug meta.category_name meta.uuid meta.name meta.created_at meta.updated_at meta.published_at meta.unpublished_at meta.slug meta.tag

URL Examples:

  • https://company.site.com/testsite?meta.category_slug=category3
  • https://company.site.com/testsite?meta.tag=tag_name
  • https://company.site.com/testsite?meta.tag[in][]=tag1_name&meta.tag[in][]=tag2_name
  • https://company.site.com/testsite?meta.created_at=1987-11-19T13:13:13

e.g. {% assign entries = widget.entries | filter_by_query_string %}

Parameters:

  • entries (ArrayEntry) — array with entries

# From Published Date

Returns a list of Entries that have a publication date more recent than the limit. e.g. {% assign entries = widgets.entries | from_published_date: date %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • date (Datetime)(default: Time.zone.now) — limit date

# Limit

Limits the number of results. e.g. {{ entries | limit: 1 }}

Parameters:

  • object(Array) — array
  • limit (Integer)(default: 1) — result limit

# Paginated

Separates the results into pages. e.g. {{ objects | paginated: 10, 2 }}

Parameters:

  • object(Array) — array
  • per_page (Integer) (default: 10) — objects per page
  • page (Integer) (default: 1) — page number to display

# Sort By

Returns an array with entries sorted by a field e.g. {% assign entries = widgets.entries | sort_by: 'name', 'asc' %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • attribute (String) — field by which you want to sort
  • order (String) - asc (ascending) or desc (descending)

# To Published Date

Returns a list of Entries that have a publication date older than the limit. e.g. {% assign entries = widgets.entries | to_published_date: date %}

Parameters:

  • entries (ArrayEntry) — array with entries
  • date (Datetime)(default: Time.zone.now) — limit date

# Crypto

These Liquid filters alter values related to Cryptography.

# Base64 Decode

Returns the Base64-decoded value of a string (e.g. {% 'Hello world' | base64_encode %} # => 'SGVsbG8gd29ybGQ=').

# Base64 Encode

Returns the Base64-encoded value of a string (e.g. {% 'SGVsbG8gd29ybGQ=' | base64_decode %} # => 'Hello world').

# HMAC SHA1

Returns the SHA-1 hash using a message authentication code (HMAC) of a string (e.g. {% 'Hello world' | hmac_sha1: 'key' %} # => '2a73959742baf046e6e2e27e5ee94bcff0af31b1').

# HMAC SHA256

Returns the SHA-256 hash using a message authentication code (HMAC) of a string (e.g. {% 'Hello world' | hmac_sha256: 'key' %} # => 'a82b2e160edaf92a6589dc11160d2a10c04449840a58717db308c1ee3512b039').

# MD5

Returns the MD5 hash of a string (e.g. {% 'Hello world' | md5 %} # => '3e25960a79dbc69b674cd4ec67a72c62').

# SHA1

Returns the SHA-1 hash of a string (e.g. {% 'Hello world' | sha1 %} # => '7b502c3a1f48c8609ae212cdfb639dee39673f5e').

# SHA 256

Returns the SHA-256 hash of a string (e.g. {% 'Hello world' | sha256 %} # => '64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c').

# CSS

These Liquid filters alter CSS-related values in Modyo Platform.

# Brighten

Adds brightness to a color (e.g. {{ '#00ff00' | brighten: 15 }} #=> '#26ff26').

# Darken

Reduces the brightness of a color (e.g. {{ '#00ff00' | darken: 15 }} #=> '#00b300').

# Desaturate

Desaturates a color (e.g. {{ '#00ff00' | desaturate: 15 }} #=> '#13ec13').

# Grayscale

Converts a color to grayscale (e.g. {{ '#00ff00' | grayscale }} #=> '#808080'). Alias: greyscale (same output).

# Lighten

Lightens a color (e.g. {{ '#00ff00' | lighten: 15 }} #=> '#4dff4d').

# Opacity

Modifies the opacity of a color (e.g. {{ '#00ff00' | opacity: 0.5 }} #=> 'rgba(0, 255, 0, 0.5)').

# RGB

Transforms a color to its RGB equivalent (e.g. {{ '#00ff00' | rgb }} #=> 'rgb(0, 255, 0)').

# Saturate

Saturates a color (e.g. {{ '#00ff00' | saturate: 15 }} #=> '#00ff00').

# Spin

Rotates a color in degrees clockwise (e.g. {{ '#00ff00' | spin: 15 }} #=> 'rgba(0, 255, 0, 0.5)').

# Location

These Liquid filters alter values related to Geolocation in Modyo Platform.

# Dynamic Map

Returns a dynamic Google Maps map (e.g. {{ locations | dynamic_map: '600x300', 'true', 'roadmap', true}}).

Parameters

  • locations (ArrayHash) — Array of hashes with latitude and longitude points.
  • size (String) (default: '600x300') — Map size in pixels.
  • zoom (String) (default: 10) — Zoom level for the map.
  • type (String) (default: 'roadmap') — Map type.
  • icon (String) (default: '') — Map icon.
  • controls (String) (default: true) — Navigation controls for the map.

# Static Map

Returns a static Google Maps map (e.g. {{ locations | static_map: '600x300', 'true', 'roadmap'}}).

Parameters

  • locations (ArrayHash) — Array of hashes with latitude and longitude points.
  • size (String) (default: '600x300') — Map size in pixels.
  • zoom (String) (default: 10) — Zoom level for the map.
  • type (String) (default: 'roadmap') — Map type.
  • icon (String) (default: '') — Map icon.

These Liquid filters alter values related to menu items in Modyo Platform.

# Active Page

Determines if a URL item is active. Returns 'active' when active (e.g. {{ 'company.modyo.com/jobs' | active_page: 'company.modyo.com/jobs' }} #=> 'active').

# Item Rel

Returns 'noopener noreferrer' if a link is "_blank" (e.g. {{ '_blank' | item_rel }} #=> 'noopener noreferrer').

# Resolve URL

Resolves the URL from a path and base URL (e.g. {{ 'dynamic_bank' | resolve_url: 'company.modyo.com' }} #=> 'company.modyo.com/dynamic_bank').

# Visible Items

Returns a list of visible items in a list of items (e.g. {{ items | visible_items }}).

# Origination

These are the liquid filters that alter values related to originations in Modyo Platform.

# By UID

Returns the Origination with the selected UID. e.g. {% assign my_origination = site.originations | by_uid: 'my-origination' %}

Parameters:

  • originations (ArrayOrigination) - array with originations
  • uid (String) - Origination UID

# Site

These Liquid filters alter values related to Sites in Modyo Platform.

# Asset image Tag

Generates the HTML tag of an image (e.g. {{ asset | asset_image_tag: 'original' }}).

Generates the HTML thumbnail tag of an image (e.g. {{ asset | asset_thumbnail_link_tag: 'class', 'target' }}).

Parameters

  • asset (Asset) — Asset-type object.
  • classes (String) (default: '') — Additional HTML classes (optional).
  • target (String) (default: '') — Additional HTML targets (optional).

# Asset URL

Generates the URL of an Asset object or a template asset path. For Asset objects using Cloudflare for image optimization, you can use the following additional parameters: width, height, blur, quality, format and fit. (e.g. {{ assets['asset_uuid'] | asset_url: blur: 40, format: 'auto', fit: 'cover' }}). For template asset paths from the template builder, specify the asset type as the second argument (e.g. {{ 'base' | asset_url: 'js' }}). You can also use the script_tag or stylesheet_tag filters to automatically generate the complete HTML