mandrill 的 handlebars 模板引擎存在命名冲突问题:其内置的 `title` 和 `url` 等全局 helper 会覆盖数据对象中同名字段,导致 `{{title}}` 在 `{{#each posts}}` 中无法正常渲染;正确做法是显式使用 `{{this.title}}` 访问当前迭代项属性。
Mandrill 并未完全兼容标准 Handlebars 规范,而是实现了定制化的 Handlebars 子集,并内置了一批同名全局 helper(如 title、url、lowercase 等),这些 helper 优先级高于模板数据中的同名字段。当你在 {{#each posts}} 中写 {{title}} 时,Mandrill 实际调用的是内置的 title helper(用于首字母大写转换),而非你数据中 {“title”: “title A”} 的原始值——而该 helper 对非字符串输入(如对象)通常返回空或默认行为,因此出现 TITLE, 后为空、THIS Array 的异常输出。
✅ 正确写法(显式访问当前上下文):
{{#each posts}}
TITLE {{this.title}}, THIS {{this}}
{{/each}}
⚠️ 注意事项: