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.
Create a Django template tag that renders MJML markup into HTML using the approach in https://github.com/wagtail/wagtail-newsletter/issues/4.
The
NewsletterPageMixin
class should provide two new methods:get_newsletter_html()
: returns the email-friendly HTML representation of the page. It should expect anewsletter_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:
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.