A prototype linter which checks the indentation and the correctness of Jinja-like/HTML templates. Can fix issues.
It works with Django’s templates too, it should work with Twig and similar template languages. It should work fine with any kind of HTML 4 and 5, hovewer XHTML is not supported.
This linter parses both HTML and Jinja tags and will report mismatched tags and indentation errors:
<div>
{% if something %}
</div>
{% endif %}
<div>
<span>
</div>
</span>
{% if something %}
<div> not indented properly
</div>
{% endif %}
{% if something %}<a href="somewhere">{% endif %}
<p>something</p>
{% if not something %}</a>{% endif %}
You need Python 3. Jinjalint doesn’t work with Python 2. Install it with
pip install jinjalint
(or pip3 install jinjalint
depending on how pip
is
called on your system), then run it with:
$ jinjalint template-directory/
…or:
$ jinjalint some-file.html some-other-file.html
This is a work in progress. Feel free to contribute 🙃