如何在 AWS SES html 模板中添加 add if 条件?

How to add add if condition in AWS SES html template?

要求是根据从 api 收到的正文数据发送模板邮件。 BodyData 可能不包含某些标签。请参阅下面的示例模板部分。

<p>{{sender}} has invited you to join team {{teamName}}</p>

所以正文数据可能不包含 teamName。所以我想在模板中将 if 条件放在 {{teamName}} 上。

请帮我找到解决办法

对于 SES 模板中的条件逻辑,您可以像在代码中一样使用 if else 语句。对于您的示例,您将使用类似

<p>{{sender}} has invited you to join team {{#if teamName}}{{teamName}}{{/if}}</p>

摘自以下文档

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-advanced.html