[BUG] [Linter] T003 should not require a name for endblock on same line
katzmo opened this issue · comments
Katharina Zwinger commented
- I'm on the latest version of djLint
- I've searched the issues
- I've read the docs
System Info
- OS: Debian 11.5
- Python Version 3.9.2
- djLint Version 1.34.0
- template language: django
Issue
T003 requires all endblocks to have a name, even if they are on the same line as the block start. That makes it impossible to add empty blocks (or blocks with very little content) in a single line, because although the formatter would put {% block myblock %}{% endblock %}
on one line, it requires a linebreak for a named endblock.
To me the formatter behavior seems sensible, I think the T003 rule should not require a name for single line blocks.
Comparison
Curently impossible:
{% block title %}{% endblock %}
{% block content %}{% endblock %}
Currently enforced (and IMHO harder to read):
{% block title %}
{% endblock title %}
{% block content %}
{% endblock content %}
How To Reproduce
- In a Django template, add
{% block myblock %}{% endblock %}
- Run
djlint --check
→ fine - Run
djlint
→ it will trigger "T003: Endblock should have name" - Fix T003 by changing the line to
{% block myblock %}{% endblock myblock %}
- Run
djlint
→ fine - Run
djlint --check
→ it want's to reformat the block into 2 lines
Contents of .djlintrc/pyproject.toml [tool.djlint]
profile = "django"
welcome commented