rschmukler / powerdrill

Mandrill, with Power
55 stars 9 forks source link

Provide template_content to a message #6

Closed a00andos closed 10 years ago

a00andos commented 10 years ago

It would be great if there was a template_content method. Template_content makes it easier for one template to be used for messages with different body content. A combination of templace_content and merge_vars can create truly dynamic mails.

For now I do this: message._templateContent = ([{name: 'body', content: 'Some body content string, maybe with embedded HTML and MergeVars'}]);

Thanks.

rschmukler commented 10 years ago

Hey, not sure I follow. One of the big advantages of mandrill is that you can use templates on their end, and then just send the variables. If you need to send just HTML, you can specify it with:

message.html('<h1> Hello World</h1>');

Not sure I understand?

a00andos commented 10 years ago

To my knowledge, Mandrill has two ways of replacing content in a template. The first method is merge_vars (global and/or "individual"), which I mainly use to replace single word. The second method is templace_content, which I use for replacing larger paragraphs of text. In the template_content it is also possible to embedd merge_vars, which makes it possible to do replacement i two layers. The first layer is a broad "wrapper" (template_content), and the second replacement is specific words. (mergeVars)

Templace_content works by replacing the content inside a HTML element with a mc:edit-tag. LIke this:

That means, if I want to replace a large chunk of text with embedded merge_vars, I can use template_content to replace only the content inside the span. Which might just be plain text and some
tags. Lets just pretend this replacement is 5-10 rows.

If I would have done this replacement with the message.html instead, the Mandrill template would not be used at all. This means, that if my only goal was to replace some paragraphs of text and still keep the design of the mail, I still have to provice the whole email as string: HTML, messy inline CSS and content. This string might be 400-500 rows instead of the 5-10 above.

I could of course just replace a whole paragraph with a merge_vars, but then I loose the ability to do replacement i two layers. I can't place a merge_var inside another merge_var. And that is where template_content come in.

I hope my rabbling make some sense =)