【问题标题】:If statement in sendgrid email templatesendgrid 电子邮件模板中的 if 语句
【发布时间】:2017-05-17 00:11:18
【问题描述】:

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

【问题讨论】:

    标签: email html-email


    【解决方案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}}
    

    【讨论】:

      猜你喜欢
      • 2011-06-15
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 2016-04-02
      • 2015-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多