django-inlinecss

by roverdotcom

roverdotcom / django-inlinecss

A Django app useful for inlining CSS (primarily for e-mails)

139 Stars 62 Forks Last release: about 1 year ago (v0.3.0) Other 97 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Build Status

About

Inlining CSS is necessary for email generation and sending but is currently a surprisingly large hassle.

This library aims to make it a breeze in the Django template language.

Usage

Step 1: Dependencies

  • BeautifulSoup
  • cssutils
  • Python 2.7+,3.4+
  • Django 1.11+

Step 2: Install django_inlinecss

Add

django_inlinecss
to your
settings.py
:
INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.webdesign',
        'django.contrib.contenttypes',
        '...',
        '...',
        '...',
        'django_inlinecss')

Step 3: Use the templatetag

  1. Place your CSS file somewhere staticfiles can find it
  2. Create your template:
{% load inlinecss %}
{% inlinecss "css/extra-padding.css" %}


        <div class="lots-o-padding">
            Something in need of styling.
        </div>

{% endinlinecss %}

Step 4: Prepare to be Wowed

    <div style="padding-left: 10px; padding-right: 10px; padding-top: 10px;" class="lots-o-padding">
        Something in need of styling.
    </div>

Acknowledgements

Thanks to Tanner Netterville for his efforts on Pynliner.

Thanks to Thomas Yip for his unit tests on the

soupselect
module. These tests helped on getting the core CSS2 selectors to work.

License

MIT license. See LICENSE.md for more detail.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.