File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -357,13 +357,12 @@ def render_footnotes(
357
357
if jinja_env is None :
358
358
jinja_env = Environment ()
359
359
360
- for part in self .docx .sections [0 ].part .package .parts :
361
- if part .content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml' :
362
- tree = etree .fromstring (part .blob )
363
- for footnote in tree .findall ('.//w:t' , docx .oxml .ns .nsmap ):
364
- if hasattr (footnote , 'text' ):
365
- footnote .text = jinja_env .from_string (footnote .text ).render (context )
366
- part ._blob = etree .tostring (tree )
360
+ for section in self .docx .sections :
361
+ for part in section .part .package .parts :
362
+ if part .content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml' :
363
+ xml = self .patch_xml (part .blob .decode ('utf8' ))
364
+ xml = self .render_xml_part (xml , part , context , jinja_env )
365
+ part ._blob = xml
367
366
368
367
def resolve_listing (self , xml ):
369
368
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created : 2024-09-23
4
+
5
+ @author: Bart Broere
6
+ """
7
+
8
+ from docxtpl import DocxTemplate
9
+
10
+ DEST_FILE = "output/footnotes.docx"
11
+
12
+ tpl = DocxTemplate ("templates/footnotes_tpl.docx" )
13
+
14
+ context = {
15
+ "a_jinja_variable" : "A Jinja variable!"
16
+ }
17
+
18
+ tpl .render (context )
19
+ tpl .save (DEST_FILE )
You can’t perform that action at this time.
0 commit comments