Skip to main content

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

Project description

[![Build Status](https://travis-ci.org/roverdotcom/django-inlinecss.png?branch=master)](https://travis-ci.org/roverdotcom/django-inlinecss)

## 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```:

```python
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:

```html
{% load inlinecss %}
{% inlinecss "css/extra-padding.css" %}
<html>
<body>
<div class='lots-o-padding'>
Something in need of styling.
</div>
</body>
</html>
{% endinlinecss %}
```

#### Step 4: Prepare to be Wowed

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

## Acknowledgements

Thanks to Tanner Netterville for his efforts on [Pynliner](https://github.com/rennat/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.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-inlinecss-0.2.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

django_inlinecss-0.2.0-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-inlinecss-0.2.0.tar.gz.

File metadata

  • Download URL: django-inlinecss-0.2.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for django-inlinecss-0.2.0.tar.gz
Algorithm Hash digest
SHA256 36707609b775e1bd6fcfeee3949ce7b7884ed335451fe0f80deb76a6e211bfba
MD5 fb34693f2b7ceeb80a539ba9a99e221f
BLAKE2b-256 5e89487e0ae73d8d2dd80045bed4854a3ffb5fe11147977901d28437eedff1a8

See more details on using hashes here.

File details

Details for the file django_inlinecss-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_inlinecss-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for django_inlinecss-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6ec6021aa03dcbe9e3f7ca0fb3dc813203e770d7a32fe8e187cc8a91aad96723
MD5 c3b2d946e86c3031689f5a244d8bcf6b
BLAKE2b-256 c7f76a4881d90115a8c926efc694f6d1cf644fb65d590d7a36fb13e1aaf2dbe3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page