diff --git a/djlint/settings.py b/djlint/settings.py index 47b23a374..bae77c416 100644 --- a/djlint/settings.py +++ b/djlint/settings.py @@ -603,6 +603,7 @@ def __init__( self.indent_template_tags: str = ( (rf"(?!{self.ignore_blocks})" if self.ignore_blocks else "") + r""" (?:if + | unless | ifchanged | for | asyncEach @@ -788,6 +789,7 @@ def __init__( (rf"(?!{self.ignore_blocks})" if self.ignore_blocks else "") + r""" (?:if + | unless | for | asyncEach | asyncAll @@ -822,6 +824,7 @@ def __init__( (rf"(?!{self.ignore_blocks})" if self.ignore_blocks else "") + r""" (?:if + | unless | endif | for | endfor @@ -1027,6 +1030,7 @@ def __init__( self.optional_single_line_template_tags: str = r""" if | for + | unless | block | with | asyncEach diff --git a/tests/test_handlebars/test_unless.py b/tests/test_handlebars/test_unless.py new file mode 100644 index 000000000..2175846e7 --- /dev/null +++ b/tests/test_handlebars/test_unless.py @@ -0,0 +1,50 @@ +"""Test handlebars each tag. + +uv run pytest tests/test_handlebars/test_each.py +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +import pytest + +from djlint.reformat import formatter +from tests.conftest import printer + +if TYPE_CHECKING: + from djlint.settings import Config + +test_data = [ + pytest.param( + ( + "