Search code examples
apimandrill

Mandrill not parsing my handlebars


I have a handlebar

{{#if imgLinkEncoded}}
<div> some content </div>
{{/if}}

For my API calls to message/send-template.json

{
    "template_name": "Fluff Tuff 3",
    "template_content": [
        {
            "content": "",
            "name": ""
        }
    ],
    "global_merge_vars": [
        {
            "content": "bhhb",
            "name": "username"
        },
        {
            "content": "asdasd",
            "name": "imgLink"
        },
        {
            "content": "asdasd",
            "name": "imgLinkEncoded"
        }
    ],
    "message": {
        "to": [
            {
                "email": "asdad@gmail.com"
            }
        ],
        "images": [
            {
                "type": "image/jpeg",
                "name": "IMAGECID",
                "content":"adasdasda"
            }
        ],
     },
     "key": "asdasd"
}

The API call succeeds and the email is sent. The division, that is dependant on handlebar imgLinkEncoded is never shown. At one place I am printing {{imgLinkEncoded}} as well, that's also not shown, hence mandrill is not recognizing my vars. I also tried the message specific merge_vars targeting the specific recipient. That also doesn't work.


Solution

  • Solved. global_merge_vars are required to be inside message.