4

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>
ensnare
  • 40,069
  • 64
  • 158
  • 224

1 Answers1

5
<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
  • 854,459
  • 170
  • 1,222
  • 1,395