Open yakky opened 4 years ago
A premailer seems interesting – what exactly would you like to transform with it?
django-post_office already has an integrated renderer. This has been added to render images as inlines into the mail body.
Premailer goes beyond that, by inlining css, prepending domain to domainless urls etc (see https://github.com/peterbe/premailer).
I agree that probably the premailer integration can be added to PostOfficeTemplates
template backend
That is nice idea. Currently i use django-inlinecss for css styles inlining and some custom templatetags to prepend domain in my projects. Probably everyone who works with django-post_office has to do something similar. The idea of having this feature out of the box is beautiful in itself, and details can be discussed in PR.
@Mogost thanks for the reply. Just a few preliminary questions:
PostOfficeTemplates
backend is the right place to implement it?I think I can have something working in a week or so
For me:
do you think PostOfficeTemplates backend is the right place to implement it?
right
should it be an optional dependency or a required one?
optional
I share @Mogost 's opinion:
- do you think PostOfficeTemplates backend is the right place to implement it?
yes
- should it be an optional dependency or a required one?
optional
btw., this feature will increase the version number to at least 3.3. What about dropping support for Python-2 there completely?
@jrief I may have misunderstood you, but the support of Py2 was droped in my PR https://github.com/ui/django-post_office/pull/283
@Mogost Ups, forgot that – sorry.
A few thoughts:
Maybe we can apply it as a template post processing step? Everytime a template is updated, we produce a "compiled" version and use that compiled version during delivery. But I wonder if this approach will work for all kinds of email.
django-inlinecss mentioned by @Mogost seems easier to integrate because it's already a Django project.
Perhaps we can also bring in a few commonly used email related template tags (like prepending domains) to post office.
This is another library that I always use in my projects dealing with emails: https://github.com/SeiryuZ/django-pancake
This allows us to use Django template tags like include
and extends
in our source code for parts like footer and headers. We then flatten our emails into one single template before putting them into post office.
A nice improvements it would be to provide a premailer integration and / or an overridable renderer which allows to customize the template rendering (https://github.com/ui/django-post_office/blob/master/post_office/models.py#L98)
I can work on this, if it's of interest