Metadata-Version: 2.1
Name: django-whiteless
Version: 1.0.0
Summary: Django template tags for dealing with pesky whitespaces
Home-page: https://github.com/denizdogan/django-whiteless
License: MIT
Keywords: django,whitespace,template,tag
Author: Deniz Dogan
Author-email: denizdogan@users.noreply.github.com
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: Django (>=2.0,<4.0)
Project-URL: Documentation, https://github.com/denizdogan/django-whiteless
Project-URL: Repository, https://github.com/denizdogan/django-whiteless.git
Description-Content-Type: text/markdown

# django-whiteless

Django template tags which deal with pesky whitespaces!

[![CircleCI](https://circleci.com/gh/denizdogan/django-whiteless/tree/master.svg?style=svg)](https://circleci.com/gh/denizdogan/django-whiteless/tree/master)

- Django 2.x and 3.x
- Python 3.7, 3.8, 3.9

## Installation

Install the latest version from PyPI:

```bash
$ pip install django-whiteless
```

Add `"whiteless"` to `INSTALLED_APPS`:

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

## Usage

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

### Remove all whitespaces

```djangotemplate
{% whiteless %}
    ...
{% endwhiteless %}
```

### Remove leading whitespaces

```djangotemplate
{% whiteless leading %}
    ...
{% endwhiteless %}
```

### Remove trailing whitespaces

```djangotemplate
{% whiteless trailing %}
    ...
{% endwhiteless %}
```

### Remove leading and trailing whitespaces

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

### Replace whitespaces with a single space

```djangotemplate
{% 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:

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

### Remove trailing whitespaces at end of file

```djangotemplate
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.

## Development

```shell
$ poetry shell
$ poetry install
$ pre-commit install  # install git hooks
$ tox  # run tests
```

## License

[MIT](LICENSE)

