Template variables
Templates are personalised with double-brace variables. Every text field on a template supports them - subject, content, textContent, fromName, rcptName, cc and bcc:
{% raw %}
Subject: Your {{ plan }} plan is ready, {{ firstName }}
Content: <p>Hi {{ firstName }}, thanks for joining.</p>
Where the values come from
When a message is sent, SendStreak builds one set of values from two sources:
- The recipient contact’s stored attributes - everything you have upserted against that contact, plus their
email. - The
variablesobject on the send request, for values that only apply to this one send.
Request values win where both supply the same name. Announcements and automations have no per-send variables, so they see contact attributes only.
Variable names are matched case-insensitively, so {{ firstName }}, {{ firstname }} and {{ FIRSTNAME }} all resolve to the same attribute. Whitespace inside the braces is ignored: {{name}} and {{ name }} are equivalent.
A name with no matching value renders as an empty string rather than failing the send. Check your attribute slugs with List attribute metas if a variable comes out blank.
Conditional blocks
A {{#name}}...{{/name}} block renders only when the value is present and non-empty; {{^name}}...{{/name}} renders only when it is absent or empty:
Hi {{#firstName}}{{ firstName }}{{/firstName}}{{^firstName}}there{{/firstName}},
Escaping
In the HTML body, values are HTML-escaped, so a contact named Tim & Co <Ltd> cannot break your markup or inject tags. This is what you want in content, and it is applied automatically.
Everywhere else - the subject line, the plain-text body, and the name and address fields - values are inserted verbatim, because nothing decodes HTML entities in those places. An apostrophe in a subject arrives as an apostrophe.
If you need to inject raw HTML into the body deliberately - a fragment you have stored as a contact attribute, for example - use triple braces to opt out of escaping:
<div>{{{ signatureHtml }}}</div>
Only do that with values you control. Triple braces in a subject or text body behave the same as double braces.
The unsubscribe link
{{ unsubscribe_link }} is reserved. It is replaced at delivery time with a per-recipient unsubscribe URL, so it resolves later than your own variables and cannot be overridden by an attribute of the same name. Announcement emails must include it.
Trying a template out
The dashboard’s template editor sends a test email with sample values, which is the quickest way to confirm a template renders the way you expect before wiring it into a send.
Try SendStreak for Free now!