[英]Python, Pyramid, Chameleon : parse Chameleon template in string
我有一個Chameleon模板存儲為字符串。 我已經以這種形式獲得它,因為我需要先進行自己的處理。 接下來,我想解析模板,可能使用“渲染響應”:
render_to_response('templates/foo.pt',
{'foo':1, 'bar':2},
request=request)
但是,我無法弄清楚如何解析存儲在字符串中的模板,而不是指向文件中的模板。 這可能嗎?
但是,我無法弄清楚如何解析存儲在字符串中的模板,而不是指向文件中的模板。 這可能嗎?
根據api文檔 ,似乎是這樣:
from chameleon import PageTemplate
t = PageTemplate('some string template')
rendered_content = t.render(encoding='utf-8')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.