Jinja unfortunately does not support executing arbitrary Python code, such as
不幸的是,Jinja不支持执行任意Python代码,例如
{% if len(some_var)>1 %} ... {% endif %}
My current workaround is to use the deprecated, ugly, double-underscore method:
我目前的解决方法是使用弃用的,丑陋的双下划线方法:
{% if some_var.__len__()>1 %} ... {% endif %}
Although this works, I'm afraid that some future implementation of strings might break this code. Is there a better way to do this?
虽然这有效,但我担心未来某些字符串的实现可能会破坏这段代码。有一个更好的方法吗?