Skip to content

Commit

Permalink
fix(formatter): fixed wild match on template tags
Browse files Browse the repository at this point in the history
closes #686
  • Loading branch information
christopherpickering committed Jun 12, 2023
1 parent 3b37ec8 commit d288b78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/djlint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -540,7 +541,7 @@ def __init__(
| set(?!(?:(?!%}).)*=)
"""
+ self.custom_blocks
+ r")"
+ r")\b"
)

self.template_indent: str = (
Expand Down
9 changes: 9 additions & 0 deletions tests/test_django/test_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
),
id="for_tag",
),
pytest.param(
("{% for i in items %}\n" " <div>{% formfield i %}</div>\n" "{% endfor %}"),
(
"{% for i in items %}\n"
" <div>{% formfield i %}</div>\n"
"{% endfor %}\n"
),
id="test nested formfield",
),
]


Expand Down

0 comments on commit d288b78

Please sign in to comment.