feat(jinja call): added support for jinja call blocks

closes #337
This commit is contained in:
Christopher Pickering 2022-08-18 15:08:16 -05:00
parent c025b249b3
commit 7a70e395d3
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 48 additions and 0 deletions

View file

@ -412,6 +412,7 @@ class Config:
| filter
| each
| macro
| call
| raw
"""
+ self.custom_blocks
@ -527,6 +528,7 @@ class Config:
| verbatim
| each
| macro
| call
| raw
"""
+ self.custom_blocks
@ -568,6 +570,8 @@ class Config:
| endmacro
| raw
| endraw
| call
| endcall
"""
+ self.custom_blocks
+ r"""

View file

@ -0,0 +1,44 @@
"""Djlint tests specific to jinja.
run::
pytest tests/test_jinja/test_call.py --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
pytest tests/test_jinja/test_call.py::test_call --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
"""
# pylint: disable=C0116
from typing import TextIO
from click.testing import CliRunner
from tests.conftest import reformat
def test_call(runner: CliRunner, tmp_file: TextIO) -> None:
output = reformat(
tmp_file, runner, b"{% call 'cool' %}<div>some html</div>{% endcall %}"
)
assert output.exit_code == 1
assert (
output.text
== r"""{% call 'cool' %}
<div>some html</div>
{% endcall %}
"""
)
output = reformat(
tmp_file, runner, b"{% call('cool') %}<div>some html</div>{% endcall %}"
)
assert output.exit_code == 1
assert (
output.text
== r"""{% call('cool') %}
<div>some html</div>
{% endcall %}
"""
)