Skip to content

Commit

Permalink
Merge pull request #426 from Riverside-Healthcare/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherpickering authored Oct 13, 2022
2 parents d69fd8f + 4a0bee6 commit d4b99ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/djlint/formatter/indent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -74,6 +75,7 @@ def indent_html(rawcode: str, config: Config) -> str:
|(?:<(?:{always_self_closing_html})\b[^>]*?/?>[ \t]*?) # <img stuff />
|(?:<(?:{slt_html})\b[^>]*?/>[ \t]*?) # <img />
|(?:{{%[ ]*?({slt_template})[ ]+?.*?%}})(?:.*?)(?:{{%[ ]+?end(\3)[ ]+?.*?%}}[ \t]*?) # >>> match 3
|{config.ignored_inline_blocks}
)
+?[^<]*?$ # with no other tags following until end of line
""",
Expand Down
1 change: 0 additions & 1 deletion tests/test_config/test_files/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# pylint: disable=C0116

import os
from pathlib import Path

from click.testing import CliRunner

Expand Down
19 changes: 19 additions & 0 deletions tests/test_html/test_tag_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span></span>{% blocktrans %}<div></div>{% endblocktrans %}
{% endblock content %}
""",
)
runner.invoke(djlint, [tmp_file.name, "--reformat"])

assert (
Path(tmp_file.name).read_text(encoding="utf8")
== """{% block content %}
<span></span>{% blocktrans %}<div></div>{% endblocktrans %}
{% endblock content %}
"""
)

0 comments on commit d4b99ef

Please sign in to comment.