fixed dj comment formatting and added test

This commit is contained in:
Christopher Pickering 2021-08-30 15:10:01 +02:00
parent 41a3346c14
commit 4d5e3b184d
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 13 additions and 1 deletions

View file

@ -14,7 +14,7 @@ ignored_block_closing = [r"</style" r"\*}", r"\?>", r"</script"]
# contents of tags will not be formated and tags will not be formatted
ignored_group_opening = [r"<!--", r"[^\{]{#", r"<pre", r"<textarea"]
ignored_group_closing = [r"-->", r"#}[^\}]", r"</pre", r"</textarea"]
ignored_group_closing = [r"-->", r"#}", r"</pre", r"</textarea"]
# the contents of these tag blocks will be indented, then unindented

View file

@ -355,3 +355,15 @@ comment-->
</div>
"""
)
def test_dj_comments_tag(runner, tmp_file):
write_to_file(
tmp_file.name,
b"""{# comment #}\n{% if this %}<div></div>{% endif %}""",
)
runner.invoke(djlint, [tmp_file.name, "--reformat"])
assert (
open(tmp_file.name).read()
== """{# comment #}\n{% if this %}<div></div>{% endif %}\n"""
)