【发布时间】:2015-06-16 17:59:30
【问题描述】:
我最近接触到了 Bottlepy,这几乎是我第一次使用模板引擎。(在此之前我会简单地用传统 PHP 制作我需要的东西)
我的问题是,假设我有一个基本布局(一个简单的 HTML/CSS 布局),例如;侧面的登录框。如何使登录框保持动态更新,而不必在每条路由上都向其传递值?
以此为例:
from bottle import route,template
@route('/')
def main():
return template("content.tpl") #rebase from layout.tpl
layout.tpl:
<html>
<head>
<title>{{title}}</title>
</head>
<body>
%include
<div id='sidebar'><!-- login box --></div>
</body>
</html>
我想我的主要问题是如何确保登录框运行而不必在每个页面上为其插入变量
【问题讨论】: