diff --git a/src/djlint/formatter/indent.py b/src/djlint/formatter/indent.py index 989d4e8..adb3e2d 100644 --- a/src/djlint/formatter/indent.py +++ b/src/djlint/formatter/indent.py @@ -64,6 +64,7 @@ def indent_html(rawcode: str, config: Config) -> str: # if a one-line, inline tag, just process it, only if line starts w/ it # or if it is trailing text + elif ( ( re.findall( @@ -74,6 +75,7 @@ def indent_html(rawcode: str, config: Config) -> str: |(?:<(?:{always_self_closing_html})\b[^>]*?/?>[ \t]*?) # |(?:<(?:{slt_html})\b[^>]*?/>[ \t]*?) # |(?:{{%[ ]*?({slt_template})[ ]+?.*?%}})(?:.*?)(?:{{%[ ]+?end(\3)[ ]+?.*?%}}[ \t]*?) # >>> match 3 + |{config.ignored_inline_blocks} ) +?[^<]*?$ # with no other tags following until end of line """, diff --git a/tests/test_config/test_files/test_config.py b/tests/test_config/test_files/test_config.py index e8c38db..443f449 100644 --- a/tests/test_config/test_files/test_config.py +++ b/tests/test_config/test_files/test_config.py @@ -11,7 +11,6 @@ run:: # pylint: disable=C0116 import os -from pathlib import Path from click.testing import CliRunner diff --git a/tests/test_html/test_tag_span.py b/tests/test_html/test_tag_span.py index ab423b6..3c6e5db 100644 --- a/tests/test_html/test_tag_span.py +++ b/tests/test_html/test_tag_span.py @@ -104,3 +104,22 @@ def test_span_leading_text(runner: CliRunner, tmp_file: TextIO) -> None: {% endif %} """ ) + + +def test_span_and_template(runner: CliRunner, tmp_file: TextIO) -> None: + write_to_file( + tmp_file.name, + b"""{% block content %} + {% blocktrans %}
{% endblocktrans %} + {% endblock content %} +""", + ) + runner.invoke(djlint, [tmp_file.name, "--reformat"]) + + assert ( + Path(tmp_file.name).read_text(encoding="utf8") + == """{% block content %} + {% blocktrans %}
{% endblocktrans %} +{% endblock content %} +""" + )