Using Filters in Templates

Modify Fomo notification messages with intuitive pseudo-code.

Fomo avatar
Written by Fomo
Updated over a week ago

Fomo templates contain sentence structures and merge tags.

They also support something we call filters. This lets you adjust the look and feel of specific Fomo notification variables (first_name, city, etc) with a bit of "syntactical sugar."

Filters are included in your templates by simply adding a "|" (pipe), then a space, then the filter name. Note: you must use a single space between the elements (variable, filter, pipe) for this to work.

You can combine multiple filters by adding a pipe between each filter, here are some examples of this:

{{ first_name | propercase | default [Someone] }}

{{ title | replace [XX Pro Plan (Midnight Special), Pro Plan] | replace [XX Ultra Plan, Ultra Plan] }} 

Here are a few of our currently supported filters...


{{ variable | number }} 

This formats numbers as comma-separated, if more than 3 digits long.


1,234 visitors are looking at this right now


{{ variable | truncate }} 

This reduces the variable's length to 30 characters.

However, you may want to specify the exact character length. Example:

Hello, World. My name is Berna...

{{ variable | truncate 15 }} 

The '15' parameter represents a custom character length of 15 characters.


Hello, World. My name is...


{{ variable | first }}

This reduces the variable to the first character. Similar to truncate, but easier for display names as initials and such. 

Input: James
Output: J


Sometimes integrations send data like "XX Pro Plan (Midnight Special)" and all you want to show off is "Pro Plan."

{{ variable | replace [XX Pro Plan (Midnight Special), Pro Plan] }} 

Just add the "replace" filter, followed by two "arguments" inside [ ] brackets.

The first argument should be the value you want to replace, then a comma, and the second argument (after the comma) should be the new value to replace it with.


Got a few pesky characters you want to ignore in a template variable?

For example, if your {{ title }} value is "Red, Shirt" you can remove the comma with:

{{ title | delete [,] }} 

In case there are multiple instances of a character, and you only want to delete one...

Ex: {{ title }} is "Some, long title, with commas"

{{ title | delete_first [,] }}  => "Some long title, with commas"
{{ title | delete_last [,] }}  => "Some, long title with commas"


If your variable lengths are unpredictable, you may be unable to use Truncate.

For that reason, we created "trim_before" and "trim_after" filters.


{{ title_with_link | trim_after [ - ] }} 

Would convert this product title:

"AX100 Hoverboard - Free Shipping 24x7"

Into this:

"AX100 Hoverboard"

Similarly, trim_before would turn this:

"MIDNIGHT SALE | Gaming Chairs"

{{ title_with_link | trim_before [ | ] }} 

Into this:

"Gaming Chairs"

To use the trim_before and trim_after filters, just place your unwanted character "delimiter" inside [ ] brackets, following the filter name and a space.


{{ variable | color #00f }}
{{ variable | color #0000ff }}

Color codes support 3 or 6 digit hexcodes, and will modify that variable's value only.

Default Fallbacks

{{ variable | fallback [some word] }} 

After a variable, space, pipe, and another space, input "fallback" and then your fallback word(s) inside square brackets. You can add nothing between the brackets (ex. "[]") for a blank fallback.


{{ first_name | default [Someone] }} --> "Someone" if first_name is blank

Random Fallbacks

{{ variable | fallback_random [A marketer,Someone great] }}

Per event (Fomo notification) created, their message would randomly be either:

  • A marketer just signed up...

  • Someone great just signed up...

Mix and match fallback_random  filters on multiple variables at once, and feel free to provide unlimited, comma-separated options, ie:

{{ first_name | fallback_random [A cool person,Someone great,An honest marketer,Your new best friend] }}


{{ variable | bold }} --> Hello, world

Self explanatory. This will bold the variable's value in your notification message.


Suppose your merge variable 'first_name' is "chRis."

{{ variable | propercase }}  --> Chris

{{ variable | upcase }}  --> CHRIS

{{ variable | downcase }}  --> chris


Count Up

If your merge variable is a number 'amount', 'visitor_count', 'count', etc. This will "count up" to your variable number as the notification displays.
{{ variable | count_up }} 


This will give your notification a little "TADA!" as the notification displays.
{{ variable | tada! }} 


Arrow color defaults to black
{{ variable | arrow }} 

To change color: {{ variable | arrow #026aa7 }}
Color codes support 3 or 6 digit hexcodes.  

State Abbreviations

Abbreviate US state names
{{ province | abbr us_state }}

From this:

to this:

Delete Linebreaks
Remove all linebreaks
{{ variable | delete_linebreaks }} 

Template Filters on Static Text

You can apply any of the template filters above to static (plain) text. Simply use [[ ]] instead of {{ }} for static text.


  • {{ time_ago }}  does not support filters (yet)

If you have any questions about using filters in your notifications, let us know.

Did this answer your question?