Reputation: 5432
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?
Upvotes: 0
Views: 289
Reputation: 174662
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')
Upvotes: 1