node.js - 邮戳模板 : dynamic variable with html processed as text instead of html

标签 node.js email templates postmark

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

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

在 Controller 中:

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.

关于node.js - 邮戳模板 : dynamic variable with html processed as text instead of html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65054422/

相关文章:

node.js - 未为 cron 作业定义注入(inject)服务

node.js - Socket.io 不适用于 nginx

node.js - 如何使用变量mongoose查询?

html - 测试 HTML 电子邮件呈现

PHP mail() 中继到邮件服务器

HTML 电子邮件 <hr/> 样式问题

templates - 在 Jinja 中动态获取变量(从字符串)

c++ - 模板函数中的名称查找规则

debugging - 从进程中将 NodeJs 应用程序切换到 Debug模式

c++ - C++11 中的 CRTP 调度