I'm new to web development and am trying to make a simple webpage in python using Pyramid. I've run into a bit of a snag though when it comes to making template files using Chameleon. What I'm trying to do right now is very simple. The view callable returns a list of dictionaries (all dictionaries have same keys just different values). I want to put these value into a table by looping through each entry in the list.
I'm having a lot of trouble finding out how to do the loop in Chameleon. Once I have a dictionary I know how to get its values for a given key. If anyone knows of a good tutorial or can just give a quick example it would be much appreciated.
You need to use "tal:repeat". If you've passed in "people" to the template, which is a list of dictionaries:
<ul>
<li tal:repeat="person people">${person['firstname']} ${person['lastname']}</li>
</ul>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.