# 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 Language | Export                              |
| ------------------- | ----------------------------------- |
| Django              | <code>{{variable&#124;safe}}</code> |
| Freemarker          | <code>${variable?no_esc}</code>     |
| Handlebars          | <code>{{{variable}}}</code>         |
| Iterable            | <code>{{{variable}}}</code>         |
| Jinja               | <code>{{variable&#124;safe}}</code> |
| Mandrill            | <code>{{{variable}}}</code>         |
| Pardot              | <code>{{{variable}}}</code>         |
| Sendgrid            | <code>{{{variable}}}</code>         |

**Escape**

| Templating Language | Export                                                     |
| ------------------- | ---------------------------------------------------------- |
| Django              | <code>{{variable&#124;escape}}</code>                      |
| Freemarker          | <code>${variable?esc}</code>                               |
| Jinja               | <code>{{variable&#124;escape}}</code>                      |
| Liquid              | <code>{{variable&#124;escape}}</code>                      |
| Marketo             | <code>allowHTML="true"</code> is added to the header tag\* |
| Responsys           | <code>${variable?html}</code>                              |

\*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.

<div class="highlight note">The Dyspatch Email Builder will not display a preview of the filtered result. It will only display the variable content.</div>

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:

| Language   | DML Input                                | Output                             |
|------------|------------------------------------------|------------------------------------|
| Django     | <code>@{var&#124;raw("func1:val&#124;func2")}</code>  | <code>{{var&#124;func1:val&#124;func2}}</code>  |
| Freemarker | <code>@{var&#124;raw("func1(val)?func2")}</code>      | <code>${var?func1(val)?func2}</code>            |
| Jinja      | <code>@{var&#124;raw("func1(val)&#124;func2")}</code> | <code>{{var&#124;func1(val)&#124;func2}}</code> |
| Liquid     | <code>@{var&#124;raw("func1:val&#124;func2")}</code>  | <code>{{var&#124;func1:val&#124;func2}}</code>  |
| Responsys  | <code>@{var&#124;raw("func1(val)?func2")}</code>      | <code>${var?func1(val)?func2}</code>            |
| AMPscript  | <code>@{var&#124;raw("func1(func2(var))")}</code>     | <code>%%=func1(func2(var))}}</code>             |
| Iterable   | <code>@{var&#124;raw("func1(func2 var)")}</code>      | <code>{{func1(func2 var)}}</code>               |
| Mandrill   | <code>@{var&#124;raw("func var")}</code>              | <code>{{func1 var}}</code>                      |

## 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(fallback string)}
```

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

| Language   | Output                                                                                                                          |
|------------|---------------------------------------------------------------------------------------------------------------------------------|
| Django     | <code>{{var&#124;default_if_none:"fallback string"}}</code>                                                             |
| Handlebars | <code>{{#if var}}{{var}}{{else}}fallback string{{/if}}</code>                                                      |
| Jinja      | <code>{{var&#124;default("fallback string")}}</code>                                                                    |
| Liquid     | <code>{{var&#124;default:"fallback string"}}</code>                                                                     |
| Marketo    | <code>${var&#124;'fallback string'}</code>                                                                              |
| AMPscript  | <code>%%[ IF Empty(@var) OR @var == "Unknown" THEN set @var = "fallback string" ENDIF ]%% %%var%%</code> |
| Iterable   | <code>{{defaultIfEmpty var "fallback string"}}</code>                                                                   |
| Mandrill   | <code>{{#if var}}{{var}}{{else}}fallback string{{/if}}</code>                                                      |
| Responsys  | <code>${var!"fallback string"}                                                                                          |