mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-16 21:40:24 +00:00
parent
400639d607
commit
a86df438b5
2 changed files with 23 additions and 3 deletions
|
|
@ -54,7 +54,9 @@ def indent_html(rawcode: str, config: Config) -> str:
|
|||
|
||||
if (
|
||||
re.findall(
|
||||
config.ignored_inline_blocks, item, flags=re.IGNORECASE | re.VERBOSE
|
||||
rf"^\s*?(?:{config.ignored_inline_blocks})",
|
||||
item,
|
||||
flags=re.IGNORECASE | re.VERBOSE | re.MULTILINE,
|
||||
)
|
||||
and is_block_raw is False
|
||||
):
|
||||
|
|
@ -150,7 +152,6 @@ def indent_html(rawcode: str, config: Config) -> str:
|
|||
)
|
||||
and is_block_raw is False
|
||||
):
|
||||
|
||||
tmp = (indent * indent_level) + item + "\n"
|
||||
indent_level = indent_level + 1
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ run::
|
|||
pytest tests/test_django/test_comments.py --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
pytest tests/test_django/test_comments.py::test_comment
|
||||
pytest tests/test_django/test_comments.py::test_nested_inline_comment
|
||||
|
||||
"""
|
||||
# pylint: disable=C0116
|
||||
|
|
@ -133,3 +133,22 @@ def test_inline_comment(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
)
|
||||
assert output.text == """{# <div></div> #}\n{% if this %}<div></div>{% endif %}\n"""
|
||||
assert output.exit_code == 0
|
||||
|
||||
|
||||
def test_nested_inline_comment(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
output = reformat(
|
||||
tmp_file,
|
||||
runner,
|
||||
b"""<div>
|
||||
{% if 1 %}
|
||||
<div class="{% if 1 %}class {% else %} class {% endif %}">
|
||||
<div class="class"
|
||||
data-parameters="{#?@ViewBag.DefaultFilters#}"
|
||||
data-target="profile-{{ profile_type }}-{{ profile_id }}">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
""",
|
||||
)
|
||||
|
||||
assert output.exit_code == 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue