开发者

In mako, how can I cycle through a list and display each value?

开发者 https://www.devze.com 2022-12-22 04:23 出处:网络
I have a Python list that I\'m supplying to the template: {\'error_name\':\'Please enter a name\', \'error_email\':\'Please enter an email\'}

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 开发者_如何学JAVAa name</li>
<li>Please enter an email</li>
</ul>


<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;-).

0

精彩评论

暂无评论...
验证码 换一张
取 消