简体   繁体   English

如何在mako模板中使用有序词典?

[英]How to use ordered dicts in mako templates?

I am using the Bunch code from here: 我正在从这里使用Bunch代码:

And it works great. 而且效果很好。 Except now I need to use Python 2.7's collections.OrderedDict and the Bunch code unorders the results. 除了现在,我需要使用Python 2.7的collections.OrderedDictBunch代码使结果无序。

I've taken a few swipes, but I'm not sure how to rewrite Bunch to support ordered dicts. 我已经刷了几下,但是我不确定如何重写Bunch以支持命令字典。 Can anyone help? 有人可以帮忙吗? My code is here: 我的代码在这里:

I ended up ditching the Bunch code in favor of the following syntax: 我最终放弃了Bunch代码,转而使用以下语法:

<span class="badge mini-classifier-pop-up" data-original-title="${classifier}"
    style="background: ${colors[stub][1]}"><i class="${icon}"></i></span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM