我正在尝试将项目数组发送到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}}它没有执行循环,不知道我做错了什么。
添加回答
举报
0/150
提交
取消