7

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?

marcelka
  • 253
  • 3
  • 11

2 Answers2

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