Skip to content

Show, hide and repeat parts of an email

This is the reference for the HTML tab of the e-mail template editor: how variables are written, how a part of an email is shown only to some recipients or repeated once for each item in a list, and which problems stop a template from being published. How to edit, preview and publish a template is in Edit the emails the platform sends.

A variable is written in capitals between two # signs, such as #CLIENT_NAME#, and is filled in when the email is sent. A template can use the variables the platform fills for that email, and nothing else: the editor lists them in its Variables panel, and a variable the template cannot be given blocks the publish.

Put data-qd-if on any element to send it only when a condition holds. The value is one name, with not in front of it to turn it around, or several of those joined by or, which holds when any one of them does:

<tr data-qd-if="client_message">
<td>#CLIENT_MESSAGE#</td>
</tr>
<p data-qd-if="not debtor_portal_link">Contact us to see your invoice.</p>
<div data-qd-if="data_result_error_source or data_result_error_target">Something went wrong.</div>

When the email is rendered, an element whose condition does not hold is removed, and the attribute is taken off one whose condition does. The attribute never reaches the recipient.

What a name is read as depends on the template:

  • Three switches, in most templates. The platform decides these per email:

    Name Shown unless the platform hides it
    payment_information the payment details block
    debtor_portal_link the link to the debtor portal
    client_message the client’s own message
  • Any other variable, named in lower case without the # signs: data-qd-if="invoice_payment_account_iban" reads #INVOICE_PAYMENT_ACCOUNT_IBAN#. The part is shown when the variable has a value and hidden when it is empty.

In the visual editor, every element has an Only when setting that writes this attribute. It offers one name at a time; a condition joined by or is written on the HTML tab, and the setting then shows it as it is. A conditional element is outlined on the canvas and labelled with its condition; a table, a table section or a row shows the outline only.

Put data-qd-each on an element to repeat what is inside it once for every item in a list. Inside, #ROW_FIELD# is replaced with the item’s value for that field:

<table>
<tbody data-qd-each="data_failed_source">
<tr>
<td>#ROW_SOURCE_ID#</td>
<td>#ROW_ERROR_MESSAGE#</td>
</tr>
</tbody>
</table>
  • What is inside the element is repeated, its text as well as its children; the element itself appears once. Inside a table, put it on the tbody so every item becomes a row.
  • A row value is written as text, so any markup in it is escaped. A missing value is written as nothing.
  • #ROW_FIELD# also works inside an attribute, such as href="#ROW_URL#".
  • An empty list leaves the element empty.

Only a few emails carry a list, such as the failed invoices in the sync reports; the other templates have nothing to repeat over.

In the visual editor, a template with lists gives every element a Repeat for each setting that writes this attribute, and the palette offers the row fields. A repeating element is outlined on the canvas like a conditional one.

The compatibility check runs on every save. An error blocks publishing and pushing; a warning does not.

Code Means
UNKNOWN_VARIABLE a variable this template is never given
INVALID_CONDITION a data-qd-if that is not one name, with or without not, or several of those joined by or
UNKNOWN_CONDITION a data-qd-if naming something this template is never given
UNKNOWN_REPEAT a data-qd-each over something this template is never given
ROW_OUTSIDE_REPEAT a #ROW_FIELD# anywhere other than inside a repeating element
FORBIDDEN_TAG a tag email clients strip or refuse, such as script, form or iframe
EVENT_HANDLER an on... attribute such as onclick
JAVASCRIPT_URL a link to javascript:
EXTERNAL_STYLESHEET, CSS_IMPORT styles loaded from elsewhere, which email clients do not fetch
CSS_VARIABLE a var(--...) custom property, which Outlook renders as nothing
TOO_LARGE a document over 100 KB, where Gmail clips the email
HANDLEBARS {{...}} from a template written for the old email provider, which nothing fills in
UNPARSEABLE HTML that cannot be read at all

It also warns, without blocking, about markup the major email clients drop or render differently, such as flexbox, a background image, or a style Outlook ignores.