From f5faadc302dea6b247da0bd8b1cb62ad5549e3f9 Mon Sep 17 00:00:00 2001 From: jdongmo Date: Sat, 20 Nov 2021 15:31:49 -0500 Subject: [PATCH] Add script to check jinja syntax --- files/check_jinja_syntax.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 files/check_jinja_syntax.py diff --git a/files/check_jinja_syntax.py b/files/check_jinja_syntax.py new file mode 100755 index 0000000..d43a52d --- /dev/null +++ b/files/check_jinja_syntax.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# filename: check_jinja_syntax.py +import sys +import os +from jinja2 import Environment, FileSystemLoader + +#for arg in sys.argv: +# print(arg) +env = Environment(loader=FileSystemLoader(sys.argv[1])) +#templates = [] +#for x in env.list_templates(): +# if x.endswith('.j2'): +# templates.append(x) +templates = [x for x in env.list_templates() if x.endswith('.j2')] +for template in templates: + print(template) + t = env.get_template(template) + env.parse(t)