Skip to content

Commit

Permalink
fix(formatter): fixed issue with spaceless macro tags having spacess …
Browse files Browse the repository at this point in the history
…added before -

closes #667
  • Loading branch information
christopherpickering committed May 30, 2023
1 parent 9b50021 commit 5593937
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/djlint/formatter/indent.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def format_function(config: Config, html: str, match: re.Match) -> str:
# format function contents
beautified_code = re.sub(
re.compile(
r"([ ]*)({{)[ ]*?((?:(?!}}).)*?\w)(\([^\)]*?\)[ ]*)((?:(?!}}).)*?}})",
r"([ ]*)({{-?\+?)[ ]*?((?:(?!}}).)*?\w)(\([^\)]*?\)[ ]*)((?:(?!}}).)*?-?\+?}})",
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE | re.DOTALL,
),
func,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_nunjucks/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
({}),
id="don't add parenth to lists",
),
pytest.param(
('{{- foo("bar") -}}'),
('{{- foo("bar") -}}\n'),
({}),
id="don't break spaceless tags #667",
),
]


Expand Down

0 comments on commit 5593937

Please sign in to comment.