A call to tpl.get_undeclared_variables() resets document rendering and returns all variables defined in the template. This conflicts with the documentation
To Reproduce
Run the code below on any template with some jinja variables.
import os.path
from docxtpl import DocxTemplate
doctemplate = r'test.docx'
if __name__ == '__main__':
doc = DocxTemplate(os.path.abspath(doctemplate))
context = {
'test': 'HelloWorld'
}
doc.render(context)
# Without the line below, rendering works fine. With this line, the rendering will be reset
print(doc.get_undeclared_template_variables())
doc.save("output.docx")
Expected behavior
tpl.get_undeclared_variables() must not reset the rendered template.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
To fix this issue, change line 47 of template.py from if not self.docx or self.is_rendered: to if not self.docx or not self.is_rendered:
Describe the bug
A call to tpl.get_undeclared_variables() resets document rendering and returns all variables defined in the template. This conflicts with the documentation
To Reproduce
Run the code below on any template with some jinja variables.
Expected behavior
tpl.get_undeclared_variables() must not reset the rendered template.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
To fix this issue, change line 47 of template.py from
if not self.docx or self.is_rendered:
toif not self.docx or not self.is_rendered:
test.docx