I'm working with Python/Pyramid and Mako Templates, and it's all pretty new for me.
I have a list over different templates, now the list comes out in a random order but I want it alphabetically. Does anyone have any suggestions? Here is the code that gets the list:
<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>
Just sort your "template_list" in python before it gets rendered in the template.