【发布时间】:2014-06-01 21:24:56
【问题描述】:
我很难掌握瓶子子模板。 理想情况下,我想做的是从 HTML 表单中获取一个值,该表单要求用户指定多个项目。然后将呈现一个子模板,该模板根据所选项目的数量创建一个表单。但是我一直无法让任何子模板正常工作。瓶子文档中的示例是这样的:
% include('header.tpl', title='Page Title')
Page Content
% include('foother.tpl')
所以我有一个名为 hello 的 .tpl 文件,如下所示:
<h1>Hello World </h1>
% include('goodbye.tpl')
还有一个名为 goodby 的 .tpl 文件,如下所示:
<h1> Goodbye World </h1>
还有一个看起来像这样的脚本:
将瓶子导入为 bt 将浏览器导入为 wb
@bt.route('/sub_template', method = 'GET')
def test():
return bt.template('hello')
def main():
wb.open('http://localhost:8080/sub_template')
bt.run(host = 'localhost', port = 8080, debug = True)
if __name__ == "__main__":
main()
但我收到:
NameError: name '_base' is not defined
我做错了什么?
谢谢
【问题讨论】:
-
我似乎使用的是 0.11 版。这是版本问题吗?
标签: html python-2.7 web bottle