heeroyuy84
heeroyuy84

Reputation: 63

Mandrill handlebars example

The variables in my html content appear to be stripped so no dynamic content is showing up in the email. The template language is set to handlebars in the code and globally.

The documentation does not appear to give any other details or examples. There are no error messages.

var subject = "A really great subject";
            var htmlContent = "<h1>Hi, {{user}}</h1><p>{{productName}}?</p><br/><a href='{{unsub redirect_merge_var}}'>Unsubscribe</a>"

var mailJSON ={
                    "key": "myKey",
                    "merge_language": "handlebars",
                    "merge": true,
                    "global_merge_vars": [
                        {
                            "name": "productName",
                            "content": "Mandrill_User1"
                        },
                        {
                            "name": "user",
                            "content": "cool guy"
                        }
                    ],
                    "message": {
                        "html": htmlContent,
                        "subject": subject,
                        "from_email": "[email protected]",
                        "from_name": "stuff-app",
                        "to": [
                            {
                                "email": ""+person.email,
                                "name": ""+person.name,
                                "type": "to"
                            }
                        ],
                        "important": false,
                        "track_opens": null,
                        "track_clicks": null,
                        "auto_text": null,
                        "auto_html": null,
                        "inline_css": null,
                        "url_strip_qs": null,
                        "preserve_recipients": null,
                        "view_content_link": null,
                        "tracking_domain": null,
                        "signing_domain": null,
                        "return_path_domain": null
                    },
                    "async": false,
                    "ip_pool": "Main Pool"
                }

Upvotes: 1

Views: 1485

Answers (1)

tosc
tosc

Reputation: 759

move this:

 "merge_language": "handlebars",
 "merge": true,
 "global_merge_vars": […],

into your message struct. (Official API documentation)

You can also remove your NULL values if you don't need them.

Upvotes: 2

Related Questions