Skip to content

Commit

Permalink
Print the name of faulty jinja templates in pre-commit (#11484)
Browse files Browse the repository at this point in the history
  • Loading branch information
VannTen authored Aug 30, 2024
1 parent 27c7dc7 commit b0be5f2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/scripts/check-templates.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#!/usr/bin/env python

import sys
import traceback
from jinja2 import Environment
from jinja2.exceptions import TemplateSyntaxError


env = Environment()
errors = False
for template in sys.argv[1:]:
with open(template) as t:
env.parse(t.read())
try:
with open(template) as t:
env.parse(t.read())
except TemplateSyntaxError as e:
print (template)
traceback.print_exc()
errors = True
if errors:
exit (1)

0 comments on commit b0be5f2

Please sign in to comment.