Merge pull request #209 from vesatoivonen/issue-208

Allow jinja environment to be passed to undeclared_template_variables
This commit is contained in:
Eric Lapouyade 2019-06-17 16:25:19 +02:00 committed by GitHub
commit 1f80377013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -558,14 +558,18 @@ class DocxTemplate(object):
self.docx.save(filename,*args,**kwargs)
self.post_processing(filename)
@property
def undeclared_template_variables(self):
def get_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)
undeclared_template_variables = property(get_undeclared_template_variables)
class Subdoc(object):
""" Class for subdocument to insert into master document """