Liquid filters

Filters change the output of a Liquid object. They are used within an output and are separated by a pipe character.

Matthew James Finkel avatar
Written by Matthew James Finkel
Updated over a week ago

Filters change the output of a Liquid object. They are placed within an object after a pipe character, with optional data supplied after a colon.

Common filters

localedate

Formats a date as per the logged in user’s language settings. 

{{ invoice.invoiced_at | localedate }}

In “English (United States),” this might output 1/12/2018 (M/D/YYY) but in other languages this might output 12/01/2018  (DD/MM/YYYY).

localedatetime

Formats the date and time as per the logged in user’s language settings.

{{ order.deliver_starts_at | localedatetime }}

In “English (United States),” this might output 1/12/2018 5:30PM (M/D/YYY 12hr clock) but in other languages this might output 12/01/2018 17:30  (DD/MM/YYYY 24hr clock).

timezone

When using now to return the date and time now, Current RMS returns the UTC time. Use timezone  to change the date and time to a particular region.

{{ 'now' | timezone:"Europe/London" | localedatetime }}

For a list of timezones, edit your user profile and check the “Timezone” drop-down.

number

A decimal precision formatter. You can specify how many decimal places you’d like to add:

{{ item.quantity | number }}
{{ item.quantity | number:3 }}

This might output:

1
1.000

currency

Formats a number using the currency symbol set in System Preferences and the user’s language settings.

{{ item.price | currency }}

This might output:

$149.00

newline_to_br

Where you’ve inserted a new line into a text field (\n ), this filter inserts an HTML break (<br> ).

{{ order.external_description | newline_to_br }}

Where the external description is...

Thanks for your interest.
Contact us if we can do anything.

...this would output:

Thanks for your interest
Contact us if we can do anything.

markdown

Tells Current to format text as Markdown.

{{ order.external_description | markdown }}

Where the external description is...

**Thank you for your interest!** Contact us if we can do _anything_.

...this would output:

Thank you for your interest! Contact us if we can do anything

String filters

append

Add information to the end of a string:

{{ order.name | append:"!" }}

capitalize

Change the output to uppercase.

{{ order.name | capitalize }}

downcase

Change the output to lowercase.

{{ order.name | downcase }}

prepend

Add information to the start of a string:

{{ order.name | prepend:"We are preparing your order: " }}

remove

Removes every occurrence of a particular substring from a string.

{{ order.name | remove:"Opportunity" }}

remove_first

Removes the first occurrence of a particular substring from a string.

{{ item.name | remove_first:"Internal" }}

truncate

Truncate a string to a particular number of characters

{{ item.name | truncate:3 }}

Maths filters

ceil

Rounds up to the nearest integer

{{ item.price | ceil }}

If the item price is 1.60, this would be 2. If the item price is 1.30, this will still be 2.

divided_by

Divides an output by a number. 

{{ item.price | divided_by:2 }}

floor

Rounds down to the nearest integer.

{{ item.price | floor }}

If the item price is 1.60, this would be 1. If the item price is 1.30, this will also be 1.

minus

Subtracts a number from an output.

{{ order.charge_including_tax_total | minus:order.tax_total }}

modulo

Divides an output by a number and returns the remainder.

plus

Adds a number to an output.

{{ item.price | plus:10 }}

round

Rounds the output to the nearest integer or specified number of decimals.

{{ item.price | round }}

If the item price is 1.60, this would be 2. If the item price is 1.30, this will be 1.

times

Multiplies an output by a number.

{{ item.price | times:2 }}

If the item price is 1.60, this would output 3.20.

Array filters

first

Returns the first item in an array.

{{ item.accessories | first }}

last

Returns the last item in an array.

{{ item.accessories | last }}

sort

Sorts an array by a given attribute.

{% assign sorted_quotations = project.quotations | sort:'name' %}
Did this answer your question?