0

Hello I've been tasked to work on a turbogears project not knowing anything about the webstack. :)

Anyways, I've been going through some turbogears tutorials and I had a question about printing a variable number of items in turbogears.

So, let's say I have a template printing cars a given owner may have. It will print year, make, model, and color. An owner may have 1-n cars.

The examples I found on line for printing one car are pretty straight forward: @expose a function that returns a dictionary containing information about one car. Then reference the dictionary in a template.

But what if the owner has several cars? How can I have a template loop over a list of cars?

I am using turbogears2, python 2.7, on debian system.

thanks.

Bitdiot
  • 1,506
  • 2
  • 16
  • 30

1 Answers1

1

You can find the whole template documentation on Genshi reference (Genshi is the template engine used by TurboGears): http://genshi.edgewall.org/wiki/Documentation/xml-templates.html

What you are looking for is the py:for attribute which will repeat the tag for each item in a list.

amol
  • 1,771
  • 1
  • 11
  • 15
  • Thanks. I was able to answer my question in a couple of hours after posting. Should I post my example? – Bitdiot Sep 26 '14 at 11:21