mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-02 19:04:51 +00:00
fixed #26, added test
This commit is contained in:
parent
7c7cac916f
commit
b2b26e9ee1
3 changed files with 19 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ next_release
|
|||
- Added rule T027 to check for unclosed in template syntax
|
||||
- Added rule T028 to check for missing spaceless tags in attributes
|
||||
- Added rule H029 to check for lowercase form method
|
||||
- Ignored djagno blocktranslate tags that do not have "trimmed" from formatter
|
||||
|
||||
0.5.9a
|
||||
------
|
||||
|
|
|
|||
|
|
@ -636,8 +636,8 @@ class Config:
|
|||
| {{-?\s*/\*\s*djlint\:off\s*\*/\s*-?}}.*?{{-?\s*/\*\s*djlint\:on\s*\*/\s*-?}}
|
||||
| <!--.*?-->
|
||||
| <\?php.*?\?>
|
||||
# | {\%[ ]trans[ ][^}]*?\%}
|
||||
| {%[ ]+?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]+?endcomment[ ]+?%}
|
||||
| {%[ ]*?blocktranslate[ ]+?((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
|
||||
| {%[ ]*?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]*?endcomment[ ]*?%}
|
||||
"""
|
||||
|
||||
self.ignored_inline_blocks: str = r"""
|
||||
|
|
@ -645,7 +645,8 @@ class Config:
|
|||
| {\*.*?\*}
|
||||
| {\#.*?\#}
|
||||
| <\?php.*?\?>
|
||||
| {%[ ]+?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]+?endcomment[ ]+?%}
|
||||
| {%[ ]*?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]*?endcomment[ ]*?%}
|
||||
| {%[ ]*?blocktranslate[ ]+?((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
|
||||
"""
|
||||
|
||||
self.optional_single_line_html_tags: str = r"""
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
for a single test, run::
|
||||
|
||||
pytest tests/test_django.py::test_attribute_include --cov=src/djlint \
|
||||
pytest tests/test_django.py::test_blocktranslate --cov=src/djlint \
|
||||
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -233,10 +233,22 @@ def test_blocktranslate(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
runner,
|
||||
b"""{% blocktranslate %}The width is: {{ width }}{% endblocktranslate %}""",
|
||||
)
|
||||
assert output["exit_code"] == 0
|
||||
assert (
|
||||
output["text"]
|
||||
== r"""{% blocktranslate %}The width is: {{ width }}{% endblocktranslate %}
|
||||
"""
|
||||
)
|
||||
|
||||
output = reformat(
|
||||
tmp_file,
|
||||
runner,
|
||||
b"""{% blocktranslate trimmed %}The width is: {{ width }}{% endblocktranslate %}""",
|
||||
)
|
||||
assert output["exit_code"] == 1
|
||||
assert (
|
||||
output["text"]
|
||||
== r"""{% blocktranslate %}
|
||||
== r"""{% blocktranslate trimmed %}
|
||||
The width is: {{ width }}
|
||||
{% endblocktranslate %}
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue