1
我想解決這個web2py
問題,我想我對發生了什麼有一些基本的誤解。在web2py中的HTML模板解析
假設我有一家商店,並且我想在我的index.html
有許多包裝盒的產品。我希望每個這樣的盒子都可以從模板中解析出來。
我試圖做的有以下架構。在控制器我有
def index():
products = db().select(db.products.ALL)
return dict(products=products)
在
index.html
:
{{for i in range(0,len(products)):}}
{{ context=dict(product=products[i]) }}
{{ =response.render('template.html', context)}}
{{pass}}
和template.html
我有類似
<div id=...> <h1> {{=product.price}} </h1>...
的問題是,結果被讀取literaly。也就是說,瀏覽時index.html
我看到html標籤:
我懷疑我的整個做法是錯誤的。應該怎麼做?