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

Add css_text option to allow css strings to be provided #87

Merged
merged 1 commit into from
Nov 14, 2014

Conversation

jonbretman
Copy link
Contributor

This adds a new option to Premailer - css_text - which allows you to pass some css in directly that should be applied to the given html.

This is very useful if you are sending thousands of emails, each one with personalised content, but that all use the same CSS file. The css file(s) can then be read once and cached and passed directly to Premailer each time, avoiding any additional disc/network IO.

Before

for recipient in recipients:
    html = render_html(recipient)
    # will read from disc every time
    html = Premailer(html, external_style='style.css').transform()
    send_email(html)

After

# read from disc once
css = read_file('style.css')
for recipient in recipients:
    html = render_html(recipient)
    # no disc IO needed
    html = Premailer(html, css_text=css).transform()
    send_email(html)

Additionally fixed some pep8/flake8 warnings.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 5d87311 on jonbretman:support-css-text into c7b40c0 on peterbe:master.

@peterbe
Copy link
Owner

peterbe commented Oct 27, 2014

This is looking promising. But I don't want to merge it until we fix that Travis runs the tests across all the known versions of Python.

See #89

@peterbe peterbe closed this Nov 14, 2014
@peterbe peterbe reopened this Nov 14, 2014
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 5d87311 on jonbretman:support-css-text into c7b40c0 on peterbe:master.

@peterbe
Copy link
Owner

peterbe commented Nov 14, 2014

Yay! It works in all versions of Python.

peterbe pushed a commit that referenced this pull request Nov 14, 2014
Add css_text option to allow css strings to be provided
@peterbe peterbe merged commit f1d6164 into peterbe:master Nov 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants