views:

73

answers:

1

I have a Python list that I'm supplying to the template:

{'error_name':'Please enter a name',
 'error_email':'Please enter an email'}

And would like to display:

<ul>
<li>Please enter a name</li>
<li>Please enter an email</li>
</ul>
+2  A: 
<ul>
% for prompt in whateveryoucalledit.values():
  <li>${prompt}</li>
% endfor
</ul>

where whateveryoucalledit it is the name under which you chose to pass that container (which, as a comment noticed, is a dict, not a list). The nice thing about mako, after all, is precisely that it's wonderfully close to Python itself (except for the need to "strop" things around a bit, and explicitly close blocks rather than just indend/deindent;-).

Alex Martelli
Reference: http://www.makotemplates.org/docs/syntax.html#syntax_control
S.Lott