I have a Chameleon template stored as a string. I've got it in this form, because I need to do my own processing first. Following that, I want to parse the template, possibly using 'render to response':
render_to_response('templates/foo.pt',
{'foo':1, 'bar':2},
request=request)
However, I can't figure out how to parse a template stored in a string, rather than pointing to one in a file. Is this possible?
However, I can't figure out how to parse a template stored in a string, rather than pointing to one in a file. Is this possible?
It seems so, according to the api documentation :
from chameleon import PageTemplate
t = PageTemplate('some string template')
rendered_content = t.render(encoding='utf-8')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.