-
-
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.
fix(formatter): reverted chained function formatting
This update reverts the formatting on of chained functions as it broke filter strings, but at the same time leaves in a fix for extra spaces that the original issue found. re #720, #704
- Loading branch information
1 parent
41fa758
commit 2ba6e3b
Showing
3 changed files
with
56 additions
and
62 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 nunjucks filters. | ||
poetry run pytest tests/test_nunjucks/test_filters.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.reformat import formatter | ||
from tests.conftest import config_builder, printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
( | ||
"{% set absoluteUrl %}{{ page.url | htmlBaseUrl(metadata.url) }}{% endset %}\n" | ||
), | ||
( | ||
"{% set absoluteUrl %}\n" | ||
" {{ page.url | htmlBaseUrl(metadata.url) }}\n" | ||
"{% endset %}\n" | ||
), | ||
({}), | ||
id="one", | ||
), | ||
pytest.param( | ||
( | ||
"{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}" | ||
), | ||
( | ||
"{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}\n" | ||
), | ||
({}), | ||
id="two", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected", "args"), test_data) | ||
def test_base(source, expected, args, nunjucks_config): | ||
args["profile"] = "nunjucks" | ||
output = formatter(config_builder(args), source) | ||
|
||
printer(expected, source, output) | ||
assert expected == output |
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