Metadata-Version: 2.4
Name: djfix
Version: 0.1.1
Summary: A safe fixer for malformed multiline Django template tags
Author: prakashtaz0091
Author-email: prakashtaz0091 <code.ing2468@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# djfix

A safe fixer for malformed multiline Django template tags.

`djfix` fixes whitespace inside multiline Django `{% ... %}` template tags without formatting or changing the surrounding HTML.

## Why?

Django template tags can be awkward to format when they span multiple lines:

```django
{% if profile and profile.is_verified or not profile and
    p_form.is_verified.value %}
```

`djfix` turns that into:

```django
{% if profile and profile.is_verified or not profile and p_form.is_verified.value %}
```

It deliberately does not modify HTML, text, or other parts of the template.

## Safety

`djfix` is intentionally conservative.
It leaves these untouched:

- single-line template tags
- content outside `{% ... %}` tags
- `{% comment %} ... {% endcomment %}` blocks
- `{% verbatim %} ... {% endverbatim %}` blocks

If a template construct isn't confidently recognized as safe to change, `djfix` should leave it alone.

## Installation

Install with `uv`:

```bash
uv tool install djfix
```

Or install it into a Python environment:

```bash
pip install djfix
```

## Usage

Check a template without modifying it:

```bash
djfix templates/home/profile.html
```

Output:

```text
Would fix: templates/home/profile.html
```

Check in CI or pre-commit mode:

```bash
djfix templates/ --check
```

`--check` exits with status `1` when files need fixing.

Apply fixes:

```bash
djfix templates/ --write
```

Output:

```text
Fixed: templates/home/profile.html
```

You can pass either files or directories:

```bash
djfix templates/
djfix templates/home/profile.html
```

## Development

Clone the repository and install the development dependencies:

```bash
uv sync
```

Run tests:

```bash
uv run pytest
```

Build the package:

```bash
uv build
```

## License

MIT
