Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

A Django template tag application for minifying block-level HTML elements only

Project description

PyPI version Build status

Django Smart Spaceless is a Django template tag application for minifying block-level HTML elements only.

It’s just like spaceless, but preserves white space between inline HTML elements. Useful for HTML where spaces directly between <a>, <strong>, and other inline elements is likely desired to be preserved. Packages the django-htmlmin project to be used as a template tag.

Install

$ pip install django-smartspaceless

Add to settings.py.

INSTALLED_APPS = [
    # ...
    'smartspaceless',
]

Usage

{% load smartspaceless_tags %}

{% smartspaceless %}
<p><a href="#">Link 1</a></p>
<p><a href="#">Link 2</a> <a href="#">Link 3</a></p>
{% endsmartspaceless %}

Result:

<p><a href="#">Link 1</a></p><p><a href="#">Link 2</a> <a href="#">Link 3</a></p>

The space between <a href="#">Link 2</a> and <a href="#">Link 3</a> is preserved. Removing that space would be bad.

Note

Please note that django-htmlmin by default uses the html5lib parser, which prepends possibly missing <html><head></head><body> and appends possibly missing </body></html> tags in an effort to create valid HTML. The template tag changes this default behavior to use html.parser, the HTML parser in Python’s standard library, which does not alter HTML fragments.

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django_smartspaceless-0.1.2-py2.py3-none-any.whl (6.6 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Jul 17, 2017
django-smartspaceless-0.1.2.tar.gz (3.3 MB) Copy SHA256 hash SHA256 Source None Jul 17, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page