我尝试使用变色龙创建模板。这是一个代码片段。
调用模块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>
我的问题是中间标签没有打印出来;怎么了?