feat(h021): allow inline styles that contain template syntax

closes #351
This commit is contained in:
Christopher Pickering 2022-08-24 08:39:11 -05:00
parent ea766722a5
commit f1a39ed289
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 6 additions and 1 deletions

View file

@ -161,7 +161,7 @@
message: Inline styles should be avoided.
flags: re.I
patterns:
- <\w+\s(?:[^>]*\s)?style=(?=[^>]*>)
- <\w+\s(?:[^>]*\s)?style=(?=((?!>|{{|{%).)*>)
- rule:
name: H022
message: Use HTTPS for external links.

View file

@ -405,6 +405,11 @@ def test_H021(runner: CliRunner, tmp_file: TextIO) -> None:
assert result.exit_code == 0
assert "H021" not in result.output
# allow template syntax inside styles
write_to_file(tmp_file.name, b'<div style="test {%"><div style="test {{">')
result = runner.invoke(djlint, [tmp_file.name])
assert "H021" not in result.output
def test_H022(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b'<a href="http://">')