Every language in your stack has a formatter and a linter. HTML templates are the exception. Generic HTML tools can't parse {% %} and {{ }}, and template engines don't care what the markup around them looks like. djLint covers that blind spot: it reformats template-heavy HTML and lints it for common mistakes, with profiles for Django, Jinja, Twig, Nunjucks, Handlebars, Liquid, Go templates and more.
pip install djlintmessy.html{% block content %}
<SECTION class="posts">
<h2>Latest posts</h2>
{%if posts%}
<ul>
{% for post in posts %}
<li>
<a href="{% url 'post' post.slug %}" class="post-link {%if post.featured%}is-featured{%endif%}" data-analytics-id="post-{{post.id}}" aria-label="Read {{post.title}}">{{post.title|title}}</a>
</li>
{% endfor %}
</ul>
{%else%}
<p>No posts yet.</p>
{%endif%}
</SECTION>
{% endblock %}
djlint messy.html --reformat --single-attribute-per-line{% block content %}
<section class="posts">
<h2>Latest posts</h2>
{% if posts %}
<ul>
{% for post in posts %}
<li>
<a
href="{% url 'post' post.slug %}"
class="post-link {% if post.featured %}is-featured{% endif %}"
data-analytics-id="post-{{ post.id }}"
aria-label="Read {{ post.title }}"
>{{ post.title|title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No posts yet.</p>
{% endif %}
</section>
{% endblock %}
readme.md:
[](https://github.com/djlint/djlint)
Add a badge to your projects readme.rst:
.. image:: https://img.shields.io/badge/html%20style-djLint-blue.svg
:target: https://github.com/djlint/djlint
Looks like this:
Contributions are welcome. Send a pr with a new feature, or checkout the issue list and help where you can.