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.
Release files for django-smartspaceless 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-smartspaceless-0.1.2.tar.gz | 3.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_smartspaceless-0.1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size:3.3 MB
Release files / django-smartspaceless-0.1.2.tar.gz
| Download URL | django-smartspaceless-0.1.2.tar.gz |
|---|---|
| Size | 3.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2336382a64be18338591c0f930434f09aabed6ff3995a48ec9e59c3b4ad8c044
|
|
BLAKE2b-256 checksum How to use checksums |
1ca831f8800ddb13f1a2c46d49fb2a5a79aca2bc8e7dfd586210c28c8bf80cab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_smartspaceless-0.1.2-py2.py3-none-any.whl
| Download URL | django_smartspaceless-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7bc695987652a25b10f573d5a8a103fa15f0bb703b26c549b3d12ed4ebed5f71
|
|
BLAKE2b-256 checksum How to use checksums |
2bc2c206b8323511a23ead292f5a43e3f5d1efff91d2b64d6fbf69d736108975
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |