Skip to content

Commit

Permalink
feat(t002): allow variables names to be used in the {% extends tag
Browse files Browse the repository at this point in the history
closes #349
  • Loading branch information
christopherpickering committed Aug 24, 2022
1 parent f1a39ed commit a5d96e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/djlint/rules.yaml
Expand Up @@ -25,7 +25,7 @@
message: Double quotes should be used in tags.
flags: re.DOTALL
patterns:
- '{%.?extends\s+?[^\"]\w+'
- "{%[ \t]*?extends[ \t]+?'[^']*'"
- rule:
name: T003
message: 'Endblock should have name. Ex: {% endblock body %}.'
Expand Down
5 changes: 5 additions & 0 deletions tests/test_linter/test_linter.py
Expand Up @@ -69,6 +69,11 @@ def test_T002(runner: CliRunner, tmp_file: TextIO) -> None:
assert result.exit_code == 1
assert "T002 1:" in result.output

# allow variable names (unquoted)
write_to_file(tmp_file.name, b"{% extends this %}")
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
assert "T002" not in result.output


def test_T003(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b"{% endblock %}")
Expand Down

0 comments on commit a5d96e7

Please sign in to comment.