diff --git a/src/djlint/settings.py b/src/djlint/settings.py index 28299093..010a24d1 100644 --- a/src/djlint/settings.py +++ b/src/djlint/settings.py @@ -520,6 +520,7 @@ def __init__( self.indent_template_tags: str = ( (rf"(?!{self.ignore_blocks})" if self.ignore_blocks else "") + r""" (?:if + | ifchanged | for | block(?!trans|translate) | spaceless @@ -540,7 +541,7 @@ def __init__( | set(?!(?:(?!%}).)*=) """ + self.custom_blocks - + r")" + + r")\b" ) self.template_indent: str = ( diff --git a/tests/test_django/test_for.py b/tests/test_django/test_for.py index 77d26c18..6dfc0444 100644 --- a/tests/test_django/test_for.py +++ b/tests/test_django/test_for.py @@ -23,6 +23,15 @@ ), id="for_tag", ), + pytest.param( + ("{% for i in items %}\n" "
{% formfield i %}
\n" "{% endfor %}"), + ( + "{% for i in items %}\n" + "
{% formfield i %}
\n" + "{% endfor %}\n" + ), + id="test nested formfield", + ), ]