我如何让Mandrill解析模板中的Handlebars标签? [英] How can I get Mandrill to parse the Handlebars tags in my template?

查看:142
本文介绍了我如何让Mandrill解析模板中的Handlebars标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Mandrill的发送模板API方法发送电子邮件。这应该不重要,但以防万一,我使用PHP。



使用正确的模板发送电子邮件,但没有任何Handlebars变量被替换他们的价值。



这是一个完整的请求,如API日志中的缩减代码所示:

  {
template_name:my-template-slug,
template_content:[
{
name :价格,
内容:$ 25
}
],
消息:{
subject:我的主题,
from_email:my@email.com,
from_name:我的名字,
to:[
{
name: Jimmy Crackcorn,
type:to,
email:jimmy@crackcorn.com
}
]
},
async:false,
ip_pool:null,
send_at:null,
key:my_api_key
}

我也尝试将我的模板简化为 {{price}}



我已经验证了发送默认设置>合并语言设置为Handlebars。



以防万一rence,我在MailChimp中创建了模板并将它发送到Mandrill,然后从变量中删除了转义的反斜杠。

把手应该在API请求中的 merge_vars global_merge_vars 参数中传递,而不是在 template_content中传递 - 用于 mc:编辑MailChimp模板语言的区域


I'm using Mandrill's send-template API method to send an email. It shouldn't matter, but just in case, I'm using PHP.

The email is delivered using the correct template, but none of the Handlebars variables are replaced with their values. Instead, they're merely removed.

Here's a full request as seen in the API Logs after reducing my code:

{
  "template_name": "my-template-slug",
  "template_content": [
    {
      "name": "price",
      "content": "$25"
    }
  ],
  "message": {
    "subject": "My Subject",
    "from_email": "my@email.com",
    "from_name": "My Name",
    "to": [
      {
        "name": "Jimmy Crackcorn",
        "type": "to",
        "email": "jimmy@crackcorn.com"
      }
    ]
  },
  "async": false,
  "ip_pool": null,
  "send_at": null,
  "key": "my_api_key"
}

I also tried simplifying my template to just {{price}}, which just sends a blank email.

I've also verified that Sending Defaults > Merge Language is set to Handlebars.

In case it makes any difference, I created the template in MailChimp and sent it to Mandrill, then removed the escaping back-slashes from the variables.

解决方案

Handlebars should be passed in the merge_vars or global_merge_vars parameters in your API request, not in template_content—which is for mc:edit regions for the MailChimp template language.

这篇关于我如何让Mandrill解析模板中的Handlebars标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆