diff --git a/CHANGES.rst b/CHANGES.rst index 8355708..b39211f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +0.5.16 (2019-01-11) +------------------- +- Force to use python-docx 0.8.7 (#170) +- Add getting undeclared variables in the template (#171) + 0.5.15 (2019-01-02) ------------------- - Added `PAGE_BREAK` feature (#168) diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 9596c6d..0af3280 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -6,7 +6,7 @@ Created : 2015-03-12 ''' import functools -__version__ = '0.5.15' +__version__ = '0.5.16' from lxml import etree from docx import Document @@ -41,14 +41,6 @@ class DocxTemplate(object): HEADER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" FOOTER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" - @property - def undeclared_template_variables(self): - xml = self.get_xml() - xml = self.patch_xml(xml) - env = Environment() - parse_content = env.parse(xml) - return meta.find_undeclared_variables(parse_content) - def __init__(self, docx): self.docx = Document(docx) self.crc_to_new_media = {} @@ -564,6 +556,14 @@ class DocxTemplate(object): self.docx.save(filename,*args,**kwargs) self.post_processing(filename) + @property + def undeclared_template_variables(self): + xml = self.get_xml() + xml = self.patch_xml(xml) + env = Environment() + parse_content = env.parse(xml) + return meta.find_undeclared_variables(parse_content) + class Subdoc(object): """ Class for subdocument to insert into master document """ diff --git a/setup.py b/setup.py index 134d3f1..32f3b38 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,10 @@ setup(name='docxtpl', author_email='elapouya@gmail.com', license='LGPL 2.1', packages=['docxtpl'], - install_requires=['six', 'python-docx', 'jinja2', 'lxml'], + install_requires=['six', + 'python-docx<=0.8.7', # newer docx package breaks header/footer management in docxtpl + 'jinja2', + 'lxml'], extras_require={'docs': ['Sphinx', 'sphinxcontrib-napoleon']}, eager_resources=['docs'], zip_safe=False)