[英]Chameleon template rendering
I am new to chameleon templates. 我是变色龙模板的新手。 i paste code snippet ..
我粘贴代码片段..
runtemp.py runtemp.py
import os
path = os.path.dirname(__file__)
from chameleon import PageTemplateLoader
templates = PageTemplateLoader(os.path.join(path, "templates"))
template = templates['mytemp.pt']
template(name='John')
print str(template.read())
mytem.pt mytem.pt
<testtag>
<innertesttag>${name}</innertesttag>
</testtag>
But the output i got is 但我得到的输出是
<testtag>
<innertesttag>${name}</innertesttag>
</testtag>
I was expectinng John in output instead od $(name) 我期待John输出而不是$(名字)
What is going wrong ? 出了什么问题? how to render template?
如何渲染模板?
template.read()
just reads the contents of the template; template.read()
只读取模板的内容; you discarded the actual rendering result. 你丢弃了实际的渲染结果。
template(name='John')
returns the rendering. template(name='John')
返回渲染。
Do this instead: 改为:
print template(name='John')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.