Lint & Format Templates HTML
Chaque langage de votre stack a son formateur et son linter, sauf vos templates HTML. Les outils HTML classiques ne comprennent pas {% %} ni {{ }}, et les moteurs de templates ignorent l'apparence du balisage. djLint comble cet angle mort : il reformate le HTML riche en syntaxe de template et détecte les erreurs courantes, avec des profils pour Django, Jinja, Twig, Nunjucks, Handlebars, Liquid, les modèles Go et plus encore.
uv tool install djlint
pip install djlint
{% 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 %}
{% 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 %}
Ça ressemble à ça:
Ajoutez un badge à vos projets:
[](https://github.com/djlint/djlint)
.. image:: https://img.shields.io/badge/html%20style-djLint-blue.svg
:target: https://github.com/djlint/djlint