I would like to add dynamic content to my e-mail, part of it being a collection of items (e.g. list of books). I would like Mandrill to render each of these items once (e.g. one table row per book). Is it possible to use for-loop in Mandrill somehow?
Asked
Active
Viewed 8,588 times
2 Answers
11
Yes! Mandrill now offers full support for dynamic iteration over a list when you use the Handlebars templating language.
Here's how to do it:

Anirvan
- 6,214
- 5
- 39
- 53
2
Note: This answer is out of date, the feature was added shortly after I wrote this post.
It is not possible (see the Note at the end this page). Their recommended solution is to use multiple mc:edit sections or variables (one per item) in the Mandrill template.
Since this cannot be done for unknown collection sizes, I decided to pre-render several e-mail parts (like header, body, footer) using a more powerful template language (mustache in my case). I send only these pre-rendered parts to Mandrill via API.

marcelka
- 253
- 3
- 11
-
3Seems like since Nov 2014 you are able to do this in Mandrill using handlebars too. http://help.mandrill.com/entries/105267476-Using-Handlebars-for-dynamic-content – stevenw00 Apr 01 '15 at 02:29
-
1@marcelka, delete outdated answers. :) – Augie Gardner Dec 06 '16 at 06:41