Mandrill-dotnet
Mandrill-dotnet copied to clipboard
Sending Arrays to email templates
In recent Mandrill blog post they describe how their handlebars based templates can easily process arrays. Can support for passing an array as a merge var be added to this library?
http://blog.mandrill.com/handlebars-for-templates-and-dynamic-content.html
Great, It was best San Valentine gift a full source code sample with this API Client C#
Is there an example for showing how to use pass an array of items in? I need the template to iterate items (example: order summary showing the items a user ordered) but the TemplateContent.content field only accepts strings instead of lists/arrays/etc.
Does this example help?
https://github.com/shawnmclean/Mandrill-dotnet/blob/master/tests/IntegrationTests/Messages/SendTemplateTests.cs#L36
No I don't think that's what loulv asked for. He means something like this: http://stackoverflow.com/a/29401083/297183 See that small code change, this supports dynamic, so it also supports arrays of strings to support objects to iterate over.
@shawnmclean Any plans to implement what @rodyvansambeek is referring to? Having the TemplateContent object support dynamic content would be very useful. I'm trying to send a template email and have it iterate over an array of strings or objects.
@shawnmclean It actually seems like the handlebars templates are rendered using the global and recipient merge variables. I was successfully have to have a template render an array of objects like:
message.AddRecipientVariable("[email protected]", "lines", new object[] {
new {
text = "one"
},new {
text = "two"
} });