为了账号安全,请及时绑定邮箱和手机立即绑定

Mandrill 模板不在阵列上循环

Mandrill 模板不在阵列上循环

繁华开满天机 2021-09-28 17:47:34
我正在尝试将项目数组发送到Mandrill模板,但它不起作用,我收到的邮件显示循环本身而不是数据。这是我的python代码:message = {    'text': '',    'html': '',    'preserve_recipients': False,    'to': [        {            'email': 'rohit@email.com',            'name': 'Rohit Khatri',            'type': 'to'        }    ],    'merge_vars': [        {            'rcpt': 'rohit@email.com',            'vars': [                {                    'name': 'name',                    'content': 'Rohit Khatri'                },                {                    'name': 'email',                    'content': 'rohit@email.com'                }            ]        }    ],    'global_merge_vars': [        {            'name': 'notifications',            'content': [                {                    'name': 'Rohit Khatri',                    'profile_picture': 'http://rohitkhatri.com/profile_picture.jpg'                },                {                    'name': 'John Doe',                    'profile_picture': 'http://johndoe.com/profile_picture.jpg'                }            ]        }    ]}api = Mandrill('MANDRILL_KEY')api.messages.send_template(    template_name = 'notification',    template_content = {},    message = message)这是模板代码:{{#each notifications}}<tr class="item">    <td valign="top" class="textContent">        <img src="{{profile_picture}}" width="50" height="75" class="itemImage"/>        <h4 class="itemName">{{name}}</h4>    </td></tr>{{/each}}这是我收到的电子邮件输出:{{#notifications}}{{name}}{{/notifications}}它没有执行循环,不知道我做错了什么。
查看完整描述

1 回答

?
烙印99

TA贡献1829条经验 获得超13个赞

我遇到了同样的问题,我在消息对象中添加了 'merge_language'=>'handlebars',它解决了我的问题。


查看完整回答
反对 回复 2021-09-28
  • 1 回答
  • 0 关注
  • 150 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信