コンテンツにスキップ

HTML テンプレートをリント&フォーマット

汎用の HTML ツールは {% %} や {{ }} を解析できず、テンプレートエンジンはその周りのマークアップがどう見えるかを気にしません。djLint は、テンプレート構文の多い HTML を再フォーマットし、よくある間違いをリントで見つけます。Django、Jinja、Twig、Nunjucks、Handlebars、Liquid、Go テンプレートなどのプロファイルを備えています。コマンドラインのほか、pre-commit フックやエディターの言語サーバーとしても使えます。

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

messy.html10 件の問題問題はありません
{% 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

お使いのテンプレート言語向けのプロファイル

バッジ

表示例:html style: djLint

プロジェクトにバッジを追加しましょう:

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

コントリビュート

コントリビューションを歓迎します。取り組む issue を選ぶか、修正や新機能のプルリクエストを作成してください。

GitHub

djLint は Christopher Pickering が Atlas プロジェクトのために作りました。現在は monosans とコントリビューターの皆さんがメンテナンスしています。