如何渲染Google App Engine模板?
我知道你可以用类似下面的方式来渲染一个模板:
template_values = {
'contacts': contacts,
'url': url,
'url_linktext': url_linktext,
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
我的问题是,如果只是一个简单的表单,用来收集数据,我该怎么渲染这个模板('addcontact.html')呢?
谢谢!
1 个回答
3
template.render这个函数需要两个参数,如果没有值要传递的话,就可以用这个空的花括号{}来表示。
所以你可以这样写:template.render(templatefile, {})