Advanced Email Syntax
Our Email Template system is built on a variant of the Liquid syntax using {{ }}
as the start and end of a syntax element. Using the Liquid Syntax can result in errors and you will receive an error prompt if we cannot parse your Liquid Syntax.
Campaign Deputy Liquid Fields
For Emails sent via the Message Center as a Campaign, the below template variables are available.
Name
{{name.first}}
The first name of the donor{{name.last}}
– The last name of the donor if available{{name.first | empty "Friend" }}
First name if available, Friend if not. Spaces in a First Name are considered as blanks forempty
{{last_contribution_this_cycle}}
– A DateTime value of the last date of a Donors contribution, if available. Cycle is the Candidate Cycle according to Campaign Finance Regulations or the current year for PACs and Non-profits.{{highest_contribution_this_cycle}}
– A Decimal value of the highest contribution for the donor, if available. Cycle is the Candidate Cycle according to Campaign Finance Regulations or the current year for PACs and Non-profits.{{total_contributions_this_cycle}}
– A Decimal value of the highest contribution for the donor, if available. Cycle is the Candidate Cycle according to Campaign Finance Regulations or the current year for PACs and Non-profits.
Common Functions
empty
Input:
{{ name.first | empty "Friend"}}
Output:Friend
multiply
Input:
{{ highest_contribution_this_cycle | multiply 1.5 }}
Output:7.50
max
Input: `{{ total_contributions_this_cycle | max 2800 }}` Output 2800
default
Input:
{{highest_contribution_this_cycle | default 5 }}
Output: 5
Fundraising Examples
To increase a donor’s highest amount while staying in compliance, you can use the following syntax (For Federal Campaigns in 2020) {{ highest_contribution_this_cycle | multiply 1.5 | default 5
| max 2800}}
If a donor has given $5, they will be asked for $7.5. If a donor has given $2,800, they will be asked for $2,800. If they have not given, they will be asked for $5.
Letting a donor know the last time they gave to change your message. Pending a hotfix to allow for this shortened version soon
{{if (last_contribution_this_cycle && (date.add_days last_contribution_this_cycle 1)) < date.now}}
It has been over {{(date.now – (date.parse model.last_contribution_this_cycle)).days}} days since your last donation.
{{ else }}
Stay active!
{{ end}}
last_contribution_this_cycle
is a date with no time attached to it and may not exist for contacts without a donor history. Checking that it does not have a value is important. If the value is blank, the last_contribution_this_cycle
will be treated as false. The &&
being the logical AND requites both sides to be set as true
.
Comments
Within a code block, Campaign Deputy supports single line comments # and multi-line comments ##:
{{ name # this is a single line comment }}
input
{{ ## This<br> is a multi<br> line<br> comment ## }}
output
As you can notice, both single line and multi-line comments can be closed by the presence of a code block exit tag }}
Literals
Strings
Campaign Deputy supports two types of strings:
regular strings enclosed by double quotes “…” or simple quotes ‘…’. Regular strings supports multiline and will interpret the following escape sequences:
\’ single quote
\” double quote
\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
\uxxxx where xxxx is a unicode hexa code number 0000 to ffff
\x00-\xFF a hexadecimal ranging from 0x00 to 0xFF
verbatim strings enclosed by backstick quotes ...
. They are, for example, useful to use with for regex patterns :
input
{{ "this is a text" | regex.split \s+ }}
output [this, is, a, test]