Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlebars tag support (used by mandrill) #42

Closed
romainyakarouler opened this issue Feb 11, 2016 · 8 comments · Fixed by #1815
Closed

Handlebars tag support (used by mandrill) #42

romainyakarouler opened this issue Feb 11, 2016 · 8 comments · Fixed by #1815

Comments

@romainyakarouler
Copy link

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!

@WeshGuillaume
Copy link
Contributor

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

@arnaudbreton
Copy link
Contributor

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!

@fabien
Copy link

fabien commented Feb 14, 2016

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.

@arnaudbreton
Copy link
Contributor

@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!

@arnaudbreton
Copy link
Contributor

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

@goldensunliu
Copy link

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

@pmorch
Copy link

pmorch commented Sep 17, 2018

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

@ivank
Copy link

ivank commented Aug 18, 2024

preprocessors can handle this now https://thoughtbot.com/blog/building-templated-emails-with-mjml though the vscode extension is not supporting this style yet.

I've added a PR to address this, but in the meantime have published a forked version with that feature enabled: https://marketplace.visualstudio.com/items?itemName=IvanKeirn.vscode-mjml-custom-path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants