0.16.5
This commit is contained in:
parent
ce23f81cbe
commit
ef09ce6277
@ -1,3 +1,9 @@
|
||||
0.16.5 (2023-01-07)
|
||||
-------------------
|
||||
- PR #467 - thanks to Slarag
|
||||
- fix #465
|
||||
- fix #464
|
||||
|
||||
0.16.4 (2022-08-04)
|
||||
-------------------
|
||||
- Regional fonts for RichText
|
||||
@ -23,9 +29,6 @@
|
||||
0.15.2 (2022-01-12)
|
||||
-------------------
|
||||
- fix #408
|
||||
|
||||
0.15.1 (2021-12-20)
|
||||
-------------------
|
||||
- Multi-rendering with same DocxTemplate object is now possible
|
||||
see tests/multi_rendering.py
|
||||
- fix #392
|
||||
|
||||
@ -4,7 +4,7 @@ Created : 2015-03-12
|
||||
|
||||
@author: Eric Lapouyade
|
||||
"""
|
||||
__version__ = '0.16.4'
|
||||
__version__ = '0.16.5'
|
||||
|
||||
# flake8: noqa
|
||||
from .inline_image import InlineImage
|
||||
|
||||
@ -43,8 +43,8 @@ class DocxTemplate(object):
|
||||
self.is_rendered = False
|
||||
self.is_saved = False
|
||||
|
||||
def init_docx(self):
|
||||
if not self.docx or self.is_rendered:
|
||||
def init_docx(self, reload: bool = True):
|
||||
if not self.docx or (self.is_rendered and reload):
|
||||
self.docx = Document(self.template_file)
|
||||
self.is_rendered = False
|
||||
|
||||
@ -755,7 +755,7 @@ class DocxTemplate(object):
|
||||
self.is_saved = True
|
||||
|
||||
def get_undeclared_template_variables(self, jinja_env: Optional[Environment] = None) -> Set[str]:
|
||||
self.init_docx()
|
||||
self.init_docx(reload=False)
|
||||
xml = self.get_xml()
|
||||
xml = self.patch_xml(xml)
|
||||
for uri in [self.HEADER_URI, self.FOOTER_URI]:
|
||||
|
||||
15
tests/doc_properties.py
Normal file
15
tests/doc_properties.py
Normal file
@ -0,0 +1,15 @@
|
||||
import os.path
|
||||
|
||||
import jinja2
|
||||
from docxtpl import DocxTemplate, InlineImage
|
||||
|
||||
doctemplate = r'templates/doc_properties_tpl.docx'
|
||||
|
||||
tpl = DocxTemplate(doctemplate)
|
||||
|
||||
context = {
|
||||
'test': 'HelloWorld'
|
||||
}
|
||||
|
||||
tpl.render(context)
|
||||
tpl.save("output/doc_properties.docx")
|
||||
BIN
tests/templates/doc_properties_tpl.docx
Normal file
BIN
tests/templates/doc_properties_tpl.docx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user