I have the following dictionary:
{0: {'Shortname': 'cabling', 'Name': 'CAT5 Cabling', 'MSRP': '$45.00'}, 1: {'Shortname': 'antenna', 'Name': 'Radio Antenna', 'MSRP': '$35.00'}}
And using Cheetah, the following section of template:
#for $item in $items
<tr>
<td>$item.Name</td>
<td>$item.MSRP</td>
</tr>
#end for
When I run the code, I get this error:
<class 'Cheetah.NameMapper.NotFound'>: cannot find 'Name'
args = ("cannot find 'Name'",)
message = "cannot find 'Name'"
In the template, line 1, in the #for declaration, I have tried separating out the key value, such as:
#for $key, $value in $items
However, I still cannot iterate over the values to get the necessary information.
Am I doing something blatantly wrong?
First off, I had problems using items as the variable name in Cheetah. Might be a reserved word or something. Something less generic might be better to use.
Secondly, since you use an outer dict with an integer as key, $item will be that integer. Which means you look for Name in an integer. So in your case with a dict like that, you might do (with a different name of the dict too):
A list like this would work with your template.