邮戳模板:html 处理为文本而不是 html 的动态变量

Postmark template: dynamic variable with html processed as text instead of html

我有一个 Postmark 电子邮件模板,其中动态变量包含 html。但是,它将 html 作为纯文本处理。

更具体地说,我有下面的代码。变量 body 被发送到电子邮件模板,但是 <br><br> 显示为文本而不是它转到下一行。

在控制器中:

const body = "Hi...<br><br> Welcome to our a new episode.";
client.sendEmailWithTemplate(
    {
        TemplateAlias: process.env.POSTMARK_TEMPLATE,
        TemplateModel: {
            body: body
        },
        From: from,
        To: email,
    });

在邮戳模板中:

<tr>
  <td>
    1. The following includes text with a br break: {{body}}
  </td>
</tr>
<tr>
  <td>
    2. This line includes a br break directly in the template: How are you? <br> Anything new?
  </td>
</tr>

这会生成一封电子邮件,其中 br 中断在位置 2 上有效,但在位置 1 上无效。在位置 1 <br> <br> 上显示为文本:“<br> <br>”。

我做错了什么?

邮戳支持提供了答案:

We normally escape HTML but you can get around that by using this syntax for the variable:

{{{body}}} or {{&body}}

The triple braces or ampersand will let you put HTML into that variable when populating your TemplateModel values.