Skip to content

Commit

Permalink
fix(formatter): fixed extra breaks added around html tags inside temp…
Browse files Browse the repository at this point in the history
…late tags

thanks @Taikono-Himazin

closes #742
  • Loading branch information
christopherpickering committed Sep 18, 2023
1 parent 78d81dc commit 6091ffb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/djlint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def __init__(
"""
)
self.template_blocks: str = r"""
{%((?!%}).)+%}
{%((?!%}).)+%}|{{((?!}}).)+}}
"""

self.ignored_linter_blocks: str = r"""
Expand Down
24 changes: 24 additions & 0 deletions tests/test_django/test_html_tags_in_template_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Test html inside template tags for tag.
poetry run pytest tests/test_django/test_html_tags_in_template_tag.py
"""
import pytest

from src.djlint.reformat import formatter
from tests.conftest import printer

test_data = [
pytest.param(
("{{ some_val | default:'some_comment1<br>some_comment2' }}"),
("{{ some_val | default:'some_comment1<br>some_comment2' }}\n"),
id="test",
),
]


@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

0 comments on commit 6091ffb

Please sign in to comment.