Skip to main content

A linter for Jinja-like templates

Project description


# jinjalint

A prototype linter which checks the indentation and the correctness of
[Jinja][jinja]-like/HTML templates. Can [fix issues][django-commit].

It works with [Django’s templates][djangotemplates] too, it should
work with [Twig](https://twig.symfony.com/) and similar template languages.

This linter parses both HTML and Jinja tags and will report mismatched
tags and indentation errors:

```html+jinja
<div>
{% if something %}
</div>
{% endif %}
```

```html+jinja
<div>
<span>
</div>
</span>
```

```html+jinja
{% if something %}
<div> not indented properly
</div>
{% endif %}
```

```html+jinja
{% if something %}<a href="somewhere">{% endif %}
<p>something</p>
{% if not something %}</a>{% endif %}
```

## Usage

Install it with `pip install jinjalint`, then run it with:

```sh
$ jinjalint template-directory/
```

…or:

```sh
$ jinjalint some-file.html some-other-file.html
```

This is a work in progress. Feel free to contribute :upside_down_face:

[jinja]: http://jinja.pocoo.org/docs/2.9/
[django-commit]: https://github.com/django/djangoproject.com/commit/14a964d626196c857809d9b3b492ff4cfa4b3f40
[djangotemplates]: https://docs.djangoproject.com/en/1.11/ref/templates/language/

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

jinjalint-0.1-py3-none-any.whl (15.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page