I am working on a website that uses jinja2 framework. I am very new to jinja and I am getting this legacy code that I need to modify.
currently what I have is to display a list of data:
<ul>{% for i in aList%}
{{aList['attr1'][0]}}, {{aList['attr1'][1]}}, {{aList['attr2'][0]}}, {{aList['attr2'][1]}}
</ul>
Knowing that aList['attr1'] stores only integer type numbers, I would like to sort this list according to x where
x = aList['attr1'][1] - aList['attr1'][0]
Currently, I avoid adding new attributes to the jinja framework, I would rather do this inline, maybe something like this
{% for i in aList|sort(attribute='x')%}
But I am just speculating, I don't know the actual implementation... Please help.
Aucun commentaire:
Enregistrer un commentaire