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.
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)
Ajoutez un badge à vos projets readme.rst:
.. image:: https://img.shields.io/badge/html%20style-djLint-blue.svg
:target: https://github.com/djlint/djlint
Ça ressemble à ça:
Les contributions sont les bienvenues. Envoyez un pr avec une nouvelle fonctionnalité, ou consultez la liste et aidez où vous pouvez.