Using DML Filters on Variables

Use the filters in this guide to explicitly control and set what rendered variable content will be.

Escape / No Escape

Dyspatch does not do any escaping by default in the email builder. Using the escape or noescape filters, you can control what the rendered output will be for dynamic variables. You can append either filter to the end of a variable in the Email Builder, Subject Line, Preheader, or within a Block.

To explicitly set no escaping for a variable:

@{variable|noescape}

To escape content for a variable:

@{variable|escape}

Filter Output

On export, if the language or platform you're working with supports either the escape or noescape options, Dyspatch will automatically wrap your variable with the supported equivalent.

Here is the complete list of supported integrations using the filters and their expected output:

NoEscape

Templating LanguageExport
Django{{variable|safe}}
Freemarker${variable?no_esc}
Handlebars{{{variable}}}
Iterable{{{variable}}}
Jinja{{variable|safe}}
Mandrill{{{variable}}}
Pardot{{{variable}}}
Sendgrid{{{variable}}}

Escape

Templating LanguageExport
Django{{variable|escape}}
Freemarker${variable?esc}
Jinja{{variable|escape}}
Liquid{{variable|escape}}
MarketoallowHTML="true" is added to the header tag*
Responsys${variable?html}

*Marketo does not support single variable escaping or unescaping. If you include a single escape to a variable, this will set the entire email to be escaped.

Email Builder Preview

The escape filter will escape the value of the variable and display the raw content.

The noescape will have no effect on the email builder preview, since we do not do any escaping by default.

Raw

The raw filter can be used as a passthrough to push through any filters or functions that are supported by your rendering system.

The Dyspatch Email Builder will not display a preview of the filtered result. It will only display the variable content.

To use the raw filter, specify your variable and append the raw filter at the end with the passthrough logic inside the quotes. For example:

@{variable|raw("passthrough function in here")}

Here is an example DML input and expected output per language:

LanguageDML InputOutput
Django@{var|raw("func1:val|func2")}{{var|func1:val|func2}}
Freemarker@{var|raw("func1(val)?func2")}${var?func1(val)?func2}
Jinja@{var|raw("func1(val)|func2")}{{var|func1(val)|func2}}
Liquid@{var|raw("func1:val|func2")}{{var|func1:val|func2}}
Responsys@{var|raw("func1(val)?func2")}${var?func1(val)?func2}
AMPscript@{var|raw("func1(func2(var))")}%%=func1(func2(var))}}
Iterable@{var|raw("func1(func2 var)")}{{func1(func2 var)}}
Mandrill@{var|raw("func var")}{{func1 var}}

Default

The default filter can be used to provide fallback for a dynamic variable in the instance that variable is not present in the data.

To use the default filter, specify your variable and append the default value within the parentheses at the end. For example:

@{variable|default(default value here)}

Here is the expected output per language for DML input of @{var|default(default value here)}:

LanguageOutput
Django{{variable|default_if_none:"default value here"}}
Handlebars{{#if variable}}{{variable}}{{else}}default value here{{/if}}
Jinja{{variable|default("default value here")}}
Liquid{{variable|default:"default value here"}}
Marketo${variable|'default value here'}
AMPscript%%[ IF Empty(@variable) OR @variable == "Unknown" THEN set @variable = "default value here" ENDIF ]%% %%variable%%
Iterable{{defaultIfEmpty variable "default value here"}}
Mandrill{{#if variable}}{{variable}}{{else}}default value here{{/if}}
Responsys${variable!"default value here"}
search icon

Didn't find what you're looking for?

Ask our support team, we're here to help!

Contact Support