Quantcast
Channel: Dyspatch Blog – Dyspatch
Viewing all articles
Browse latest Browse all 259

How to use template-specific Jinja variables with Snippets

$
0
0

Recently, we received a question from a customer that prompted us to scratch our heads for a few seconds: “How can I use template-specific variables that aren’t passed into the data field of the API to send mail?” We did some research and devised a pretty simple and interesting solution.

The idea is to set up a Snippet which includes a variable of your choosing. Then you can set that Jinja variable separately in each template.

Snippet Setup

You can insert a variable into the snippet that will be pulled from the template

Once you have your variable in the snippet, all you have to do is set it in the template, like so:

Set the Jinja variable

set variable, call snippet, profit

In doing this you’ll be able to have the contents of the snippet render in the template using the previously set Jinja variable. There are tons of really cool possibilities for taking advantage of this method like building tracking urls and split testing your branding.

If you have any questions about how this works or you come up with another interesting use case, we’d love to hear from you: support@sendwithus.com


Viewing all articles
Browse latest Browse all 259

Trending Articles