Mjml: Handlebars tag support (used by mandrill)

Created on 11 Feb 2016  路  7Comments  路  Source: mjmlio/mjml

Hello,

Mandrill and Mailchimp support Handlebars template syntax, could we imagine a command like mjml -r template.mjml -o template.html --syntax=handlebars or mjml -r template.mjml -o template.html --syntax=mailchimp ?

Example:

replacement_html_ __users_romainnorberg_documents_jobs_web_calendrier_fonctionnel_web_template_mail

Links:

Thank u, Mjml is great!

Discussion

Most helpful comment

Hi @romainyakarouler,

In my opinion, the role of MJML is to render a responsive HTML email layout. That said, for your use-case, I would recommend to wrap all the handlebars templating tags with an mj-raw tag so the engine keep them when rendering the MJML.

Once you have the HTML code, you can pass it to handlebar, with the right execution context so it outputs an HTML ready to be sent.

Does it make sense to you? Hope I haven't missed something here!

Let us know how that works for you!

All 7 comments

That's a point, but allowing multiple template languages would be heavy right? Maybe we could implement a preprocessor in another repo like mjml-hbs

Hi @romainyakarouler,

In my opinion, the role of MJML is to render a responsive HTML email layout. That said, for your use-case, I would recommend to wrap all the handlebars templating tags with an mj-raw tag so the engine keep them when rendering the MJML.

Once you have the HTML code, you can pass it to handlebar, with the right execution context so it outputs an HTML ready to be sent.

Does it make sense to you? Hope I haven't missed something here!

Let us know how that works for you!

Would it be necessary to wrap those handlebar tags in mj-raw to even keep them in the final output? I would expect those to be treated as verbatim text, but perhaps this is not possible as you say? What about non mj tags like <h1>, do we need to wrap them as well? Ideally, allowing some basic tags would make sense.

@fabien, yes, for now it is a known limitation of our engine. Because of the way we parse the DOM, we need a tag to wrap even basic text/HTML element/tags. This is actually the main reason why we needed to introduce such tag. That said, this is obviously something we're aiming to improve in a near future.

Keep you posted on our progress here!

Hey @romainyakarouler, did my comment help you moving forward on your issue? Thanks!

@arnaudbreton would be nice to have an example for the mj-raw to wow the users right away. currently the documentation seems very minimal

Also worth noting that <mj-raw> tags (apparently) need to be inside either <mj-head> or <mj-body>.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zarikadzer picture zarikadzer  路  3Comments

fmauNeko picture fmauNeko  路  3Comments

lucasnantonio picture lucasnantonio  路  4Comments

liminspace picture liminspace  路  3Comments

theVannu picture theVannu  路  3Comments