Skip to main content

Django template tags for dealing with pesky whitespaces

Project description

django-whiteless

Django template tags which deal with pesky whitespaces!

CircleCI

Installation

Install the latest version from PyPI:

$ pip install django-whiteless

Add "whiteless" to INSTALLED_APPS:

INSTALLED_APPS = (
    # ...
    "whiteless",
)

Usage

The library consists of two template tags, {% whiteless %} and {% eof %}. This is how you use them.

Remove all whitespaces

{% whiteless %}
    ...
{% endwhiteless %}

Remove leading whitespaces

{% whiteless leading %}
    ...
{% endwhiteless %}

Remove trailing whitespaces

{% whiteless trailing %}
    ...
{% endwhiteless %}

Remove leading and trailing whitespaces

{% whiteless leading trailing %}
    ...
{% endwhiteless %}

Replace whitespaces with a single space

{% whiteless space %}
    ...
{% endwhiteless %}

Note that if there are leading or trailing whitespaces in the block, those will also be replaced by a single space. In order to remove leading and trailing whitespaces and replace all other whitespaces with a single space, use:

{% whiteless space leading trailing %}
    ...
{% endwhiteless %}

Remove trailing whitespaces at end of file

Hello there!{% eof %}

This is useful if e.g. your project style guide requires all files to end with a newline but that causes issues with your template.

Note that {% eof %} cannot be used inside other tags. It only removes whitespaces that immediately follow itself.

License

MIT

Project details


Download files

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

Files for django-whiteless, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size django_whiteless-0.1.3-py2.py3-none-any.whl (5.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-whiteless-0.1.3.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page