Salta ai contenuti

Analizza e formatta i template HTML

Gli strumenti HTML generici non sanno interpretare {% %} e {{ }}, e ai motori di template non importa che aspetto abbia il markup che li circonda. djLint riformatta l'HTML ricco di sintassi di template e lo analizza alla ricerca degli errori più comuni, con profili per Django, Jinja, Twig, Nunjucks, Handlebars, Liquid, template Go e altri ancora. Si usa dalla riga di comando, come hook di pre-commit e come server di linguaggio nel tuo editor.

uv tool install djlint
pip install djlint
npm i -g djlint

messy.html10 problemiNessun problema
{% block content %}<SECTION H009 Tag names should be lowercase. class='posts' H008 Attributes should be double quoted.> H014 Found extra blank lines.<h2>Latest posts</h2>{%if posts%} T001 Variables should be wrapped in a whitespace.<ul>{% for post in posts %}<li><a href="{% url 'post' post.slug %}" class='post-link' H008 Attributes should be double quoted. aria-label="Read {{post.title}}" T001 Variables should be wrapped in a whitespace.>{{post.title}} T001 Variables should be wrapped in a whitespace.</a></li>{% endfor %}</ul>{%else%} T001 Variables should be wrapped in a whitespace.<p>No posts yet.</p>{%endif%} T001 Variables should be wrapped in a whitespace.</SECTION H009 Tag names should be lowercase.>{% 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"                           aria-label="Read {{ post.title }}">{{ post.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"                            aria-label="Read {{ post.title }}"                        >{{ post.title }}</a>                    </li>                {% endfor %}            </ul>        {% else %}            <p>No posts yet.</p>        {% endif %}    </section>{% endblock %}
djlint messy.html --reformat

Un profilo per il tuo linguaggio di template

Badge

Ecco come appare:html style: djLint

Aggiungi un badge ai tuoi progetti:

[![html style: djLint](https://img.shields.io/badge/html%20style-djLint-blue.svg)](https://djlint.com)

Contribuire

I contributi sono benvenuti. Scegli una issue su cui lavorare, oppure apri una pull request con una correzione o una nuova funzionalità.

GitHub

djLint è stato creato da Christopher Pickering per i progetti Atlas. Oggi lo mantengono monosans e tutte le persone che contribuiscono.