-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(formatter): added support for jazzband's sorl-thumbnail tags
closes #714
- Loading branch information
1 parent
502562e
commit 86122dc
Showing
2 changed files
with
46 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,42 @@ | ||
"""Test jazzband sorl-thumbnail tag. | ||
https://github.com/jazzband/sorl-thumbnail | ||
poetry run pytest tests/test_django/test_thumbnail.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.reformat import formatter | ||
from tests.conftest import printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
( | ||
'{% thumbnail person.profile_photo "200x200" crop="center" as im %}\n' | ||
' <img src="{{ im.url }}"\n' | ||
' width="{{ im.width }}"\n' | ||
' height="{{ im.height }}"\n' | ||
' class="img-thumbnail"\n' | ||
' alt="{{ person.name }}">\n' | ||
"{% endthumbnail %}\n" | ||
), | ||
( | ||
'{% thumbnail person.profile_photo "200x200" crop="center" as im %}\n' | ||
' <img src="{{ im.url }}"\n' | ||
' width="{{ im.width }}"\n' | ||
' height="{{ im.height }}"\n' | ||
' class="img-thumbnail"\n' | ||
' alt="{{ person.name }}">\n' | ||
"{% endthumbnail %}\n" | ||
), | ||
id="thumbnail", | ||
), | ||
] | ||
|
||
|
||
@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 |