fixed #144, added test

This commit is contained in:
Christopher Pickering 2021-11-24 09:18:58 +01:00
parent c295354ec5
commit ec60646b36
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
3 changed files with 36 additions and 4 deletions

View file

@ -1,6 +1,10 @@
Changelog
=========
next release
------------
- Added support for django `blocktrans` tag
0.6.2
-----
- Bug fixes

View file

@ -636,8 +636,9 @@ class Config:
| {{-?\s*/\*\s*djlint\:off\s*\*/\s*-?}}.*?{{-?\s*/\*\s*djlint\:on\s*\*/\s*-?}}
| <!--.*?-->
| <\?php.*?\?>
| {%[ ]*?blocktranslate[ ]+?((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
| {%[ ]*?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]*?endcomment[ ]*?%}
| {%[ ]*?blocktranslate\b((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
| {%[ ]*?blocktrans\b((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktrans[ ]*?%}
| {%[ ]*?comment\b[^(?:%})]*?%}.*?{%[ ]*?endcomment[ ]*?%}
"""
self.ignored_inline_blocks: str = r"""
@ -645,8 +646,9 @@ class Config:
| {\*.*?\*}
| {\#.*?\#}
| <\?php.*?\?>
| {%[ ]*?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]*?endcomment[ ]*?%}
| {%[ ]*?blocktranslate[ ]+?((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
| {%[ ]*?comment\b[^(?:%})]*?%}.*?{%[ ]*?endcomment[ ]*?%}
| {%[ ]*?blocktranslate\b((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
| {%[ ]*?blocktrans\b((?!%}|trimmed).)*?%}.*?{%[ ]*?endblocktrans[ ]*?%}
"""
self.optional_single_line_html_tags: str = r"""

View file

@ -254,6 +254,32 @@ def test_blocktranslate(runner: CliRunner, tmp_file: TextIO) -> None:
"""
)
output = reformat(
tmp_file,
runner,
b"""{% blocktrans %}The width is: {{ width }}{% endblocktrans %}""",
)
assert output["exit_code"] == 0
assert (
output["text"]
== r"""{% blocktrans %}The width is: {{ width }}{% endblocktrans %}
"""
)
output = reformat(
tmp_file,
runner,
b"""{% blocktrans trimmed %}The width is: {{ width }}{% endblocktrans %}""",
)
assert output["exit_code"] == 1
assert (
output["text"]
== r"""{% blocktrans trimmed %}
The width is: {{ width }}
{% endblocktrans %}
"""
)
def test_trans(runner: CliRunner, tmp_file: TextIO) -> None:
output = reformat(