fix template filter with quote

This commit is contained in:
elapouya 2015-05-11 12:50:35 +02:00
parent 423b3005ef
commit 0f1569188d
3 changed files with 10 additions and 2 deletions

View File

@ -1,3 +1,7 @@
0.1.5 (2015-05-11)
------------------
- fix template filter with quote
0.1.4 (2015-03-27)
------------------
- add RichText support

View File

@ -5,7 +5,7 @@ Created : 2015-03-12
@author: Eric Lapouyade
'''
__version__ = '0.1.4'
__version__ = '0.1.5'
from lxml import etree
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}
src_xml = re.sub(pat, r'\1 \2',src_xml,flags=re.DOTALL)
src_xml = src_xml.replace(r"&#8216;","'")
return src_xml
def render_xml(self,src_xml,context):
with open('/tmp/titi','w') as fh:
fh.write(src_xml)
template = Template(src_xml)
dst_xml = template.render(context)
dst_xml = dst_xml.replace('{_{','{{').replace('}_}','}}').replace('{_%','{%').replace('%_}','%}')

View File

@ -24,7 +24,7 @@ News
""" % read('README', 'CHANGES')
setup(name='docxtpl',
version='0.1.4',
version='0.1.5',
description='Python docx template engine',
long_description=long_description,
classifiers=[