我試圖用變色龍創建模板。這是一個snipet代碼。變色龍模板循環
調用模塊runtemp.py
:
delete_list=[]
delete={'Name':'aaa','Sirname':'bbb','Friends':['ccc','ddd','eee']}
delete_list.append(delete)
templates = PageTemplateLoader(os.path.join(path, "templates"))
template = templates["delete_user.pt"]
print template(tdelete_list=delete_list)
模板文件delete_list.pt
:
<?xml version="1.0" encoding="UTF-8"?>
<Delete>
<DeleteRequest>
<DeleteItems tal:repeat="deletions tdelete_list">
<Deleteuser tal:repeat="delete repeat.deletions" >
<Name tal:content="repeat.delete.Name"></Name>
<Sirname tal:content="repeat.delete.Sirname"></Sirname>
<Friends>
<Friend tal:repeat="friend repeat.delete.Friends">
<Value tal:content="friend"></Value>
</Friend>
</Friends>
</Deleteuser>
<DeleteItems>
</DeleteRequest>
</Delete>
輸出我得到:
<Delete>
<DeleteRequest>
<DeleteItems>
</DeleteItems>
</DeleteRequest>
</Delete>
我的問題是沒有得到印中間的標籤;哪裏不對?