if sendgrid电子邮件模板中的语句

时间:2017-05-17 00:11:18

标签: email html-email

我正在为Sendgrid构建电子邮件模板。有没有办法在模板中插入if语句,检查是否存在来自服务器的变量,并显示或隐藏在电子邮件中显示该变量的行?

1 个答案:

答案 0 :(得分:1)

SendGrid将HandleBars用于动态模板。要有条件地渲染某些东西,可以使用:

{{#if user.profile.male}}
  <p>Dear Sir</p>
{{else if user.profile.female}}
  <p>Dear Madame</p>
{{else}}
  <p>Dear Customer</p>
{{/if}}