【发布时间】:2016-05-09 20:27:49
【问题描述】:
我正在使用 Python/Pyramid 和 Mako 模板,这对我来说都是全新的。
我有一个包含不同模板的列表,现在列表以随机顺序出现,但我希望它按字母顺序排列。 有没有人有什么建议? 这是获取列表的代码:
<div class="panel-small">
<h2>Choose template</h2>
<div id="template_list">
% if template_list and len(template_list) > 0:
% for template in template_list:
% if template['template']:
<a href="#${template['type']}_${template['template_id']}" id="${template['template_id']}" class="template_link ${template['type']}">${template['name']}<br />
% else:
% if template['url'] is not None and template['url'].startswith('mailto'):
<a href="${template['url']}" class="external">${template['name']}</a><br />
% else:
<a href="${template['url']}" class="external" target="_blank">${template['name']}</a><br />
% endif
% endif
% endfor
% else:
No template.
% endif
</div>
</div>
【问题讨论】: