Building a Code Template

Dyspatch provides an advanced code editor which allows you to build and modify your templates. This guide will list the Dyspatch features you can use in the code editor and explain how to utilize them to create an email.

This article is for the legacy code editor only.

Dyspatch Snippets

Snippets are perfect for when you have repeated blocks of code across multiple email templates. For example, a common use case for Snippets would be the headers and footers of your email. Both of these are used to maintain consistency across all of your emails which makes them an ideal candidate for Snippets. If you ever need to edit your header, instead of editing every individual email to adjust certain aspects like colors, links, or copy, all you would need to do is modify the single snippet for the changes to be reflected in your emails.

Best of all, this is simple to do! Create a snippet:

The Snippet editor with example snippet code

And reference the snippet in your template:

{% snippet "Greeting" %}

To learn more about snippets, read our Introduction to Snippets article.

Dynamic Email Content

Personalizing the content of an email is important to help convey the message of your email. Implementing the use of dynamic content provides you a way to personalize your emails more than just adding a first name.

Dyspatch code templates use the powerful Jinja Templating language, which provides the ability to add conditional logic to your emails. As long as your team has the data for a customer, the email will render customized with the specific content you have provided for that customer.

For example, you can personalize an email using the customer's location, products viewed, previous purchases, etc. This will allow you to display content tailored to the customer's interest, helping to drive conversions.

Dyspatch uses Jinja version 2.10.

Testing with Sample Data

In the template editor, there is a tab called Sample Data. This section provides you the ability to preview your template variables with a test data set. You can customize this data set to match the variables you have in your email template which will give you a better understanding of what the email will look like with actual content.

The sample data in this tab will only work if the JSON is properly formatted.


Hi, {{ first_name }}!

Thanks for purchasing!
Here is a summary of your order:

Item: {{ }}
Add on: {{ item.desc }}
Quantity: x{{ item.quan }}

Total: ${{ item.price }}

Sample Data Tab:

  "first_name": "Bill",
  "item": {
    "name": "Cupcakes",
    "desc": "With Sprinkles!",
    "quan": 12,
    "price": 24.56

Preview (Results):

Hi, Bill!

Thanks for purchasing!
Here is a summary of your order:

Item: Cupcakes
Add on: With Sprinkles!
Quantity: x12

Total: $24.56

Test Emails on Email Clients

When building a template the key to success is making sure you test it. Testing can range from all aspects of the email, from the structure, CSS formatting, proper button styling, copy, etc.

We recommend testing what your template will look like across multiple email clients. Dyspatch Device Testing provides a great and simple way of previewing your email across many different email clients.

Didn't find what you're looking for?

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

Contact Support