You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SendGrid动态模板高级条件逻辑配置技术求助

SendGrid动态模板Handlebars条件逻辑实现

1. 基于RateType开头匹配的实现

利用SendGrid Handlebars环境内置的startsWith和or helper实现开头匹配逻辑:

{{#if (startsWith RateType "A")}}
ABC
{{else if (startsWith RateType "B")}}
DEF
{{else if (or (startsWith RateType "C") (startsWith RateType "D") (startsWith RateType "E"))}}
GHI
{{else}}
JKL
{{/if}}

注:绝大多数SendGrid环境默认支持startsWith helper,若遇到未启用的情况,可通过自定义helper补充。

2. 基于TransactionNumber精确匹配的实现

使用eq(精确相等)和or helper组合处理多值匹配:

{{#if (or (eq TransactionNumber "123") (eq TransactionNumber "456"))}}
ABC
{{else if (or (eq TransactionNumber "789") (eq TransactionNumber "000"))}}
DEF
{{else}}
GHI
{{/if}}

注:若TransactionNumber传入的是数字类型而非字符串,需去掉引号(如(eq TransactionNumber 123)),根据实际数据类型调整。

内容的提问来源于stack exchange,提问作者Felix13th

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 23:29:57