0

I have the following dictionary and I've returned this as part of my view

items = { 'studentlist' : [ {'name':'alice', 'value':22}, 
                      {'name':'bob', 'value':11},
                      {'name':'charlie', 'value':33} ] }            
return items

and in my template I have:

<li tal:repeat="student studentlist" />
   <a href="">${student.name}</a>
</li>

and it's returning an error. As far as I can see this is exactly the same as:

Trouble repeating elements using TAL, Chameleon and Pyramid

The error I'm getting is this, but as far as I can see the repeat should have a 'student' and 'name' is one such element, what's going wrong?

thanks for any help.

NameError: student

- Expression: "${student.name}"
- Filename:   ... n2014_Neil\templates\neil.pt
- Location:   (line 3: col 23)
- Source:     <a href="">${student.name}</a>
                         ^^^^^^^^^^^^^^^
- Arguments:  request: <Request - at 0x54df9d0>
           renderer_info: <RendererHelper - at 0x4bcbc10>
           repeat: {...} (0)
           renderer_name: templates/neil.pt
           context: <DefaultRootFactory None at 0x54df3f0>
           req: <Request - at 0x54df9d0>
           studentlist: <list - at 0x54dd648>
           view: <NeilViews - at 0x54df470>
Community
  • 1
  • 1
Neil Walker
  • 6,400
  • 14
  • 57
  • 86
  • This does not answer your question, but have you considered using Mako as your templating engine instead? I find Mako much more intuitive and it works nicely with Pyramid. – mauzel Jan 26 '15 at 20:10
  • thanks, but I'd then have to go down the route of learning something new again and all the pitfalls of it not working and getting further help – Neil Walker Jan 26 '15 at 20:25

1 Answers1

0

Sorry, I found the answer, I was dumb :(

I should have put the repeat in the ul block not the li

Neil Walker
  • 6,400
  • 14
  • 57
  • 86