djLint
djLint copied to clipboard
[FEATURE] [Formatter] Single-line nested blocks are broken up
Issue
It seems that DjLint currently breaks up single-line nested blocks into multiple lines which inserts meaningful whitespace in HTML templates.
How To Reproduce
Create a file called html.j with the following contents:
{% block title %}{% block subtitle %}{% endblock %} | example{% endblock %}
Run DJLint as follows:
$ djlint --check test.html.j --indent 2 --profile jinja
Checking 1/1 files
test.html.j
---
@@ -1 +1,4 @@
-{% block title %}{% block subtitle %}{% endblock %} | example{% endblock %}
+{% block title %}
+ {% block subtitle %}{% endblock %}
+ | example
+{% endblock %}
1 file would be updated.
I understand that the issue can be mitigated with whitespace control, however, in some cases it would be preferable if simple nested blocks are kept untouched. Perhaps a command-line option would be useful that lets such blocks be preserved.
see also #583, #182, #165
Currently, these tags are all broken out onto multiple lines. You may take a look at the djhtml package which will only add indentation to your html.