Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Last active June 21, 2018 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/b73804732fa6d043f8930507158761a2 to your computer and use it in GitHub Desktop.
Save mrchrisadams/b73804732fa6d043f8930507158761a2 to your computer and use it in GitHub Desktop.
A rough sketch for how mjml and django-mail-builder would work
msg = build_message('email/welcome.email', {'user': request.user})
msg.send()
{% load mjml %}
{% block subject %}Thanks for signing up to Awesome Site!{% endblock %}
{% block to %}{{ user.email }}{% endblock %}
{% block body %}
Thanks for joining our site!
We hope you love how awesome it is!
{% endblock %}
{% comment %}
As far as I can tell, this this would work by expanding our all the django variables declared,
*then* the contents in the mjml block would be rendered to create the compiled html.
Or does this happen before?
https://github.com/liminspace/django-mjml/blob/master/mjml/templatetags/mjml.py#L18
{% endcomment %}
{% block html %}
{% mjml %}
<mjml>
<mj-body>
<mj-container>
<mj-section>
<mj-column>
<mj-text>Thanks for joining our site! </mj-text>
<mj-text>We hope you love how awesome it is!</mj-text>
</mj-column>
</mj-section>
</mj-container>
</mj-body>
</mjml>
{% endmjml %}
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment