bottle模板嵌套

1
2
3
4
5
6
7
8
9
10
11
12
#模版的扩展名随意
# 模板见:./bottle模版嵌套AB.tpl



from bottle import route, run, template
@route('/')
def index():
return template('bottle模版嵌套A.tpl')


run(port='8088',debug=True, reloader=True)

file: bottle模版嵌套A.tpl

1
2
3
4
5
6
7
8
9
10
11
12
<!doctype html>
<html>
<head>
<!--用中文必须声明编码-->
<meta charset='utf-8'>
<title> 标签名</title>
<h2>标题 </h2>
</head>
<body>
% include('bottle模版被嵌套B.tpl')
</body>
</html>

file: bottle模版嵌套B.tpl

1
<p>hello word</p>

转载请注明来源 https://tianweiye.github.io