Formatting template variables

Waypoint uses LiquidJS to populate the dynamic parts of the template (see template variables). This means all of the standard Liquid filters are available to use.

Below are some of our favorites:

Default

Allows you to specify a fallback in case a value doesn’t exist (without having to use a more complex conditional).

Data:

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

Input:

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

Output:

Hi there

Capitalize

Makes the first character of a string capitalized.

Data:

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

Input:

{{user.role | capitalize}}

Output

Admin

Truncate

Shortens a string down to the number of characters passed as an argument.

Input:

{{ "Build and send emails, faster than ever." | truncate: 25 }}

Output

Build and send emails...

Custom filters

Waypoint also offers set of custom built-in filters that extend LiquidJS and is available for use within Waypoint templates.

Currency

Format a number with a currency. Defaults to USD.

Input:

{{ 40.5 | currency }}

Output

$40.50

Currency codes and locales can be passed in as options to format a number to localized currency (defaults to 'en-US'):

Input:

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

Output:

10,00 €

Pluralize

Provides a singular and plural version of a word based on a number.

Input:

1 {{ 1 | pluralize: 'friend', 'friends' }}

Output

1 friend