【发布时间】:2013-03-21 01:49:51
【问题描述】:
为什么 max_height 会产生无效的语法错误?
main.py
max_height = 70
template_values = {
'max_height': max_height # syntax error
...
}
index.html
<html>
<body>
{% for person in people %}
{% if person.filter("height <", max_height %)
<b>{{ person.first_name }}</b>
<b>{{ person.last_name }}</b>
<b>{{ person.city }}</b>
<b>{{ person.birth_year }}</b>
<b>{{ person.height }}</b>
<hr></hr>
{% endif %}
{% endfor %}
</body>
</html>
编辑 1 这是 main.py 中的 MainPage 类:
class MainPage(webapp2.RequestHandler):
def get(self):
people_query = Person.all()
people = people_query.fetch(10)
max_height = 70
template_values = {
'people': people
'max_height': max_height
}
template = jinja_environment.get_template('index.html')
self.response.out.write(template.render(template_values))
【问题讨论】:
标签: google-app-engine python-2.7 jinja2