Reputation: 5088
Is it possible to do some sort of eval
in tornado templates?
Let me show an example of what I wish to do:
{% for c in columns %}
<!-- cdata is a dictionary, and columns is a list -->
<div class="cell"> {{ cdata[ {{ c }} ] }} </div>
{% end %}
e.g. I want to evaluate the current value in columns
, and use it as a key to search in the cdata
dictionary.
How do I do that?
Thanks
Upvotes: 0
Views: 184
Reputation: 22134
Expressions in Tornado templates cannot be nested, but they're just python expressions, which gives you the flexibility to do what you want. This includes calling the python eval
if that's what you need, but it looks like in this case you simply need {{ cdata[c] }}
.
Upvotes: 2