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...
Number
{{ variable | number }}
This formats numbers as comma-separated, if more than 3 digits long.
Example:
1,234 visitors are looking at this right now
Truncation
{{ 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.
Output:
Hello, World. My name is...
First
{{ 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
Replace
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.
Delete
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"
Trimming
If your variable lengths are unpredictable, you may be unable to use Truncate.
For that reason, we created "trim_before" and "trim_after" filters.
Example:
{{ 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.
Colors
{{ 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.
Example:
{{ 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] }}
Bold
{{ variable | bold }}
--> Hello, world
Self explanatory. This will bold the variable's value in your notification message.
Casing
Suppose your merge variable 'first_name' is "chRis."
{{ variable | propercase }}
--> Chris
{{ variable | upcase }}
--> CHRIS
{{ variable | downcase }}
--> chris
Animations
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 }}
Tada!
This will give your notification a little "TADA!" as the notification displays.{{ variable | tada! }}
Arrow
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.
Limitations
{{ time_ago }}
does not support filters (yet)
If you have any questions about using filters in your notifications, let us know.