Skip to content

Commit

Permalink
fix(formatter): fixed isolated quotes being deleted from attributes
Browse files Browse the repository at this point in the history
closes #652
  • Loading branch information
christopherpickering committed Jun 12, 2023
1 parent e716ddc commit 19425f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/djlint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def __init__(
| ({self.template_if_for_pattern}
"""
+ r"""
| (?:\'|\") # allow random trailing quotes
| {{.*?}}
| {\#.*?\#}
| {%.*?%})
Expand Down
24 changes: 23 additions & 1 deletion tests/test_django/test_quoted.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test django quoted tags.
poetry run pytest tests/test_django/test_filter.py
poetry run pytest tests/test_django/test_quoted.py
"""
import pytest

Expand All @@ -23,6 +23,28 @@
),
id="issue #640",
),
pytest.param(
(
'<a {% if piece.owner == request.user %} class="disabled {% if not piece.like_count %}hidden{% endif %}"\n'
" {% else %}\n"
' hx-post="x"\n'
" {% endif %}>\n"
" test\n"
" {% if piece.like_count %}<span>{{ piece.like_count }}</span>{% endif %}\n"
"</a>\n"
),
(
'<a {% if piece.owner == request.user %} class="disabled {% if not piece.like_count %}hidden{% endif %}\n'
' "\n'
" {% else %}\n"
' hx-post="x"\n'
" {% endif %}>\n"
" test\n"
" {% if piece.like_count %}<span>{{ piece.like_count }}</span>{% endif %}\n"
"</a>\n"
),
id="issue #652",
),
]


Expand Down

0 comments on commit 19425f9

Please sign in to comment.