mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-03 06:00:23 +00:00
parent
4089cb841e
commit
946b8ad715
2 changed files with 27 additions and 4 deletions
|
|
@ -199,11 +199,26 @@
|
|||
flags: re.I
|
||||
patterns:
|
||||
# for tags with 3/5/7... quotes
|
||||
- "{%((?:(?!'|\"|%}).)*?(\"|')(?:(?!\\2|%}).)*?\\2(?:(?!\\2|%}).)*?)*\\2(?:(?!\\2|%}).)*?%}"
|
||||
- "{{((?:(?!'|\"|}}).)*?(\"|')(?:(?!\\2|}}).)*?\\2(?:(?!\\2|}}).)*?)*\\2(?:(?!\\2|}}).)*?}}"
|
||||
# for single quotes
|
||||
- "{%((?:(?!'|%}).)*?(')(?:(?!\\2|%}).)*?\\2(?:(?!\\2|%}).)*?)*\\2(?:(?!\\2|%}).)*?%}"
|
||||
# for double quotes
|
||||
- "{%((?:(?!\"|%}).)*?(\")(?:(?!\\2|%}).)*?\\2(?:(?!\\2|%}).)*?)*\\2(?:(?!\\2|%}).)*?%}"
|
||||
|
||||
# for single quotes
|
||||
- "{{((?:(?!'|}}).)*?(')(?:(?!\\2|}}).)*?\\2(?:(?!\\2|}}).)*?)*\\2(?:(?!\\2|}}).)*?}}"
|
||||
# for double quotes
|
||||
- "{{((?:(?!\"|}}).)*?(\")(?:(?!\\2|}}).)*?\\2(?:(?!\\2|}}).)*?)*\\2(?:(?!\\2|}}).)*?}}"
|
||||
|
||||
# for tags with a single quote
|
||||
- "{%((?:(?!'|\"|%}).)*?(\"|')(?:(?!\\2|%}).)*?)%}"
|
||||
- "{{((?:(?!'|\"|}}).)*?(\"|')(?:(?!\\2|}}).)*?)}}"
|
||||
# for double quotes
|
||||
- "{%((?:(?!\"|%}).)*?(\")(?:(?!\\2|%}).)*?)%}"
|
||||
# for single quotes
|
||||
- "{%((?:(?!'|%}).)*?(')(?:(?!\\2|%}).)*?)%}"
|
||||
|
||||
# for double quotes
|
||||
- "{{((?:(?!\"|}}).)*?(\")(?:(?!\\2|}}).)*?)}}"
|
||||
# for single quotes
|
||||
- "{{((?:(?!'|}}).)*?(')(?:(?!\\2|}}).)*?)}}"
|
||||
- rule:
|
||||
name: T028
|
||||
message: Consider using spaceless tags inside attribute values. {%- if/for -%}
|
||||
|
|
|
|||
|
|
@ -593,6 +593,14 @@ def test_T027(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "T027" not in result.output
|
||||
|
||||
# test mixed quotes
|
||||
write_to_file(
|
||||
tmp_file.name,
|
||||
b"{% macro rendersubmit(buttons=[], class=\"\", index='', url='', that=\"\" , test='') -%}",
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"])
|
||||
assert "T027" not in result.output
|
||||
|
||||
|
||||
def test_T028(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"<a href=\"{% blah 'asdf' -%}\">")
|
||||
|
|
|
|||
Loading…
Reference in a new issue