Skip to content

Formatting template variables

Waypoint uses LiquidJS to render the dynamic parts of a template (see template variables), so all the standard Liquid filters work out of the box.

A few of our favorites:

Use | default to set a fallback when a value is missing — no need for a separate conditional. Example:

Data

{
"user": {
"fullName": ""
}
}

Input

Hi {{user.fullName | default: 'there'}}

Output

Hi there

Use | capitalize to uppercase the first character of a string. Example:

Data

{
"user": {
"role": "admin"
}
}

Input

{{user.role | capitalize}}

Output

Admin

Use | truncate to shorten a string to a given character count. Example:

Data

{
"website": {
"description": "Build and send emails, faster than ever."
}
}

Input

{{ website.description | truncate: 25 }}

Output

Build and send emails...

Waypoint adds a few custom filters on top of the standard LiquidJS set, available in any Waypoint template.

Use | currency to format a number as currency. Defaults to USD. Example:

Input

{{ 40.5 | currency }}

Output

$40.50

Pass a currency code and locale to format for a specific region (defaults to ‘en-US’):

Input

{{ 10 | currency: 'EUR', 'fr-FR'}}

Output

10,00 €

Use | pluralize to pick the singular or plural form of a word based on a number.

Data

{
"user": {
"followersCount": 1
}
}

Input

{{user.followersCount}} {{ user.followersCount | pluralize: 'friend', 'friends' }}

Output

1 friend