4

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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
dpuzz
  • 41
  • 2

1 Answers1

7

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>
Chris McDonough
  • 2,479
  • 18
  • 18