mandrill 的 handlebars 模板引擎存在内置同名辅助函数(如 `title`、`url`),会覆盖数据对象中的同名字段,导致 `{{title}}` 在 `{{#each posts}}` 中无法正确渲染;应改用 `{{this.title}}` 显式访问当前上下文属性。
Mandrill 并未使用标准 Handlebars 实现,而是基于其定制版本,并内置了一批全局同名辅助函数(helpers),例如 title(用于首字母大写)、url(用于 URL 编码)、lowercase、uppercase 等。当你的数据中恰好包含名为 title 的字段(如 {“title”: “title A”}),Mandrill 会优先调用内置 title helper 而非读取原始数据字段——这正是你收到 “TITLE, THIS Array” 的根本原因:{{title}} 被当作 helper 执行(无参数时返回空字符串),而 {{this}} 则被序列化为 “Array” 字符串。
✅ 正确写法(显式访问当前迭代项):
{{#each posts}}
TITLE {{this.title}}, THIS {{this}}
{{/each}}
⚠️ 错误写法(触发内置 helper 冲突):