Using DML Filters on Variables

Use the following filters in this guide to explicity control and set what the 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 equilivalent.

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 filter or functions that is 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}}
search icon

Didn't find what you're looking for?

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

Contact Support