How can I get Mandrill to parse the Handlebars tags in my template?

£可爱£侵袭症+ 提交于 2019-12-24 13:46:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/32392266/how-can-i-get-mandrill-to-parse-the-handlebars-tags-in-my-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!