【发布时间】:2012-11-29 22:45:43
【问题描述】:
我有以下base.html 文件,它充当继承它的所有其他文件的主要框架。
<%! import cherrypy %>
<!DOCTYPE html>
<html>
<body>
<div class="container">
<% attribute='defaultValue' %>
${attribute}
<p>
${self.body()}
</p>
</div>
</body>
</html>
现在我有另一个继承base.html 的文件,我们将其命名为foo.html:
<%inherit file="base.html" />
Whatever... ${anotherAttribute}
html 文件将在 Python 文件中以lookup.get_template('foo.html') 调用。
我可以通过lookup.get_template('foo.html').render(anotherAttribute='bar') 访问anotherAttribute。现在我想知道如何访问base.html 中的attribute?
【问题讨论】: