콘텐츠로 이동

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.html문제 10개문제 없음
{% 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)

기여하기

기여를 환영합니다. 작업할 이슈를 고르거나, 수정 사항이나 새 기능을 담은 풀 리퀘스트를 열어 주세요.

GitHub

djLint는 Christopher Pickering가 Atlas 프로젝트를 위해 만들었습니다. 지금은 monosans와 기여해 주시는 모든 분이 관리합니다.