fix template filter with quote
This commit is contained in:
parent
423b3005ef
commit
0f1569188d
@ -1,3 +1,7 @@
|
|||||||
|
0.1.5 (2015-05-11)
|
||||||
|
------------------
|
||||||
|
- fix template filter with quote
|
||||||
|
|
||||||
0.1.4 (2015-03-27)
|
0.1.4 (2015-03-27)
|
||||||
------------------
|
------------------
|
||||||
- add RichText support
|
- add RichText support
|
||||||
|
|||||||
@ -5,7 +5,7 @@ Created : 2015-03-12
|
|||||||
@author: Eric Lapouyade
|
@author: Eric Lapouyade
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__version__ = '0.1.4'
|
__version__ = '0.1.5'
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from docx import Document
|
from docx import Document
|
||||||
@ -54,9 +54,13 @@ class DocxTemplate(object):
|
|||||||
pat = r'<w:%(y)s[ >](?:(?!<w:%(y)s[ >]).)*({%%|{{)%(y)s ([^}%%]*(?:%%}|}})).*?</w:%(y)s>' % {'y':y}
|
pat = r'<w:%(y)s[ >](?:(?!<w:%(y)s[ >]).)*({%%|{{)%(y)s ([^}%%]*(?:%%}|}})).*?</w:%(y)s>' % {'y':y}
|
||||||
src_xml = re.sub(pat, r'\1 \2',src_xml,flags=re.DOTALL)
|
src_xml = re.sub(pat, r'\1 \2',src_xml,flags=re.DOTALL)
|
||||||
|
|
||||||
|
src_xml = src_xml.replace(r"‘","'")
|
||||||
|
|
||||||
return src_xml
|
return src_xml
|
||||||
|
|
||||||
def render_xml(self,src_xml,context):
|
def render_xml(self,src_xml,context):
|
||||||
|
with open('/tmp/titi','w') as fh:
|
||||||
|
fh.write(src_xml)
|
||||||
template = Template(src_xml)
|
template = Template(src_xml)
|
||||||
dst_xml = template.render(context)
|
dst_xml = template.render(context)
|
||||||
dst_xml = dst_xml.replace('{_{','{{').replace('}_}','}}').replace('{_%','{%').replace('%_}','%}')
|
dst_xml = dst_xml.replace('{_{','{{').replace('}_}','}}').replace('{_%','{%').replace('%_}','%}')
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -24,7 +24,7 @@ News
|
|||||||
""" % read('README', 'CHANGES')
|
""" % read('README', 'CHANGES')
|
||||||
|
|
||||||
setup(name='docxtpl',
|
setup(name='docxtpl',
|
||||||
version='0.1.4',
|
version='0.1.5',
|
||||||
description='Python docx template engine',
|
description='Python docx template engine',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user