-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(formatter): fixed an edge case wild regex grab
When a close template tag was following a quoted attribute on the same line, and was also following an html tag that had a quoted attribute.. line breaks were not inserted correctly. Thanks @timoludwig closes #640
- Loading branch information
1 parent
6520f63
commit 0d57e75
Showing
2 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Test django quoted tags. | ||
poetry run pytest tests/test_django/test_filter.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.reformat import formatter | ||
from tests.conftest import printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
( | ||
"<h1>\n" | ||
' {% if condition1 %}<span class="cls"></span>{% endif %}\n' | ||
' {% if condition2 %}"{{ text }}"{% endif %}\n' | ||
" </h1>\n" | ||
), | ||
( | ||
"<h1>\n" | ||
' {% if condition1 %}<span class="cls"></span>{% endif %}\n' | ||
' {% if condition2 %}"{{ text }}"{% endif %}\n' | ||
"</h1>\n" | ||
), | ||
id="issue #640", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected"), test_data) | ||
def test_base(source, expected, django_config): | ||
output = formatter(django_config, source) | ||
|
||
printer(expected, source, output) | ||
assert expected == output |