Added compatibility with Python 2.7 as to the method escape_values.
This commit is contained in:
parent
d5335cb36f
commit
4564fed0b3
@ -181,7 +181,7 @@ class DocxTemplate(object):
|
||||
"""Escape string values of the passed :dict: `d` in-place
|
||||
including nested dictionaries of any depth.
|
||||
"""
|
||||
for k, v in d.items():
|
||||
for k, v in six.iteritems(d):
|
||||
if isinstance(v, dict):
|
||||
identity = id(v)
|
||||
if identity not in identities:
|
||||
|
||||
@ -3,10 +3,10 @@ from docxtpl import *
|
||||
tpl = DocxTemplate("test_files/escape_tpl_auto.docx")
|
||||
|
||||
context = {'myvar': R('"less than" must be escaped : <, this can be done with RichText() or R()'),
|
||||
'myescvar':'It can be escaped with a "|e" jinja filter in the template too : < ',
|
||||
'nlnp' : R('Here is a multiple\nlines\nstring\aand some\aother\aparagraphs\aNOTE: the current character styling is removed'),
|
||||
'myescvar': 'It can be escaped with a "|e" jinja filter in the template too : < ',
|
||||
'nlnp': R('Here is a multiple\nlines\nstring\aand some\aother\aparagraphs\aNOTE: the current character styling is removed'),
|
||||
'mylisting': Listing('the listing\nwith\nsome\nlines\nand special chars : <>&'),
|
||||
'autoescape': """These string should be auto escaped for an XML Word document which may contain <, >, &, ", and '."""
|
||||
'autoescape': """<, >, &, ", and '."""
|
||||
}
|
||||
|
||||
tpl.render(context, autoescape=True)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user