Skip to content
On this page

Variables ‚Äč

Variables allows to dynamically serve the same template with different data, for example for different users.
They're just an object, so you can use whatever type you want and with whatever depth. For example, we could define the user name (string), the purchased items (array) and an optional call to action (object).

  "subject": "Thank you for your purchase"
  "recipient": "",
  "variables": {
    "name": "Foo",
    "items": [
      "Item 1",
      "Item 2",
    "callToAction": {
      "label": "Review your order",
      "url": ""

Then, in our template, we can display and interact with these variables, such as displaying a section of code only if a variable exists.

<!DOCTYPE html>
    <title>My Webpage</title>
    <h1>Thank you for your order!</h1>
    <p>Yo {{ name }}, this is the recap of your order:</p>

    {% for item in items %}
      <li>{{ item }}</li>
    {% endfor %}

    {% if callToAction %}
      <a href="{{ callToAction.url }}" target="_blank">
        {{ callToAction.label }}
    {% endif %}