我正在嘗試將項(xiàng)目數(shù)組發(fā)送到Mandrill模板,但它不起作用,我收到的郵件顯示循環(huán)本身而不是數(shù)據(jù)。這是我的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}}它沒(méi)有執(zhí)行循環(huán),不知道我做錯(cuò)了什么。
Mandrill 模板不在陣列上循環(huán)
繁華開(kāi)滿天機(jī)
2021-09-28 17:47:34