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

Render email content with MJML #16

Closed
mgax opened this issue Apr 29, 2024 · 0 comments · Fixed by #29
Closed

Render email content with MJML #16

mgax opened this issue Apr 29, 2024 · 0 comments · Fixed by #29

Comments

@mgax
Copy link
Member

mgax commented Apr 29, 2024

Create a Django template tag that renders MJML markup into HTML using the approach in #4.

The NewsletterPageMixin class should provide two new methods:

  • get_newsletter_html(): returns the email-friendly HTML representation of the page. It should expect a newsletter_template attribute on the Page class, that contains the name of a Django template, used to render the HTML; if the attribute has not been set, it should throw a useful exception, with guidance on how to fix it.
  • get_newsletter_context(): returns the template context for rendering the content. By default it returns {"page": self}. Can be overridden by subclasses.

The result of get_newsletter_html should be displayed in the editor preview, in a new preview mode named Newsletter.


Here is a minimal page that can be rendered as a newsletter:

class NewsletterPage(NewsletterPageMixin, Page):
    newsletter_template = "myapp/newsletter.html"
    body = RichTextField()

If the user chooses to use django-mjml (or even another rendering system than MJML), they should be able to do so, simply by changing the template.

@mgax mgax mentioned this issue May 16, 2024
Merged
@mgax mgax closed this as completed in #29 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant