-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: indentation for handlebars unless
- Loading branch information
Jordy Boer
committed
Feb 13, 2025
1 parent
a2d69bb
commit 7210120
Showing
2 changed files
with
54 additions
and
0 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,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( | ||
( | ||
"<html lang='en'> <head> <meta charset='UTF-8' /> <meta name='viewport' content='width=device-width, initial-scale=1' /> <title></title> <link href='css/style.css' rel='stylesheet' /> </head> <body> {{#unless}} <div> <p></p> </div> {{/unless}}</body></html>" | ||
), | ||
( | ||
"<html lang='en'>\n" | ||
" <head>\n" | ||
" <meta charset='UTF-8' />\n" | ||
" <meta name='viewport' content='width=device-width, initial-scale=1' />\n" | ||
" <title></title>\n" | ||
" <link href='css/style.css' rel='stylesheet' />\n" | ||
" </head>\n" | ||
" <body>\n" | ||
" {{#unless}}\n" | ||
" <div>\n" | ||
" <p></p>\n" | ||
" </div>\n" | ||
" {{/unless}}\n" | ||
" </body>\n" | ||
"</html>\n" | ||
), | ||
id="unless_tag", | ||
) | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected"), test_data) | ||
def test_base(source: str, expected: str, handlebars_config: Config) -> None: | ||
output = formatter(handlebars_config, source) | ||
|
||
printer(expected, source, output) | ||
assert expected == output |