From b01f033d14939ba8560f85f55b8e71c53a39802c Mon Sep 17 00:00:00 2001 From: Vesa Toivonen Date: Wed, 12 Jun 2019 10:54:57 +0300 Subject: [PATCH] Allow jinja environment to be passed to undeclared_template_variables --- docxtpl/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 1cc6eca..2730918 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -558,11 +558,13 @@ class DocxTemplate(object): self.docx.save(filename,*args,**kwargs) self.post_processing(filename) - @property - def undeclared_template_variables(self): + def undeclared_template_variables(self, jinja_env=None): xml = self.get_xml() xml = self.patch_xml(xml) - env = Environment() + if jinja_env: + env = jinja_env + else: + env = Environment() parse_content = env.parse(xml) return meta.find_undeclared_variables(parse_content)