鑑於我有兩個變量{{ profile }}
,其值爲「test」,而{{ element.author }}
的值爲「test」。在jinja2中,當我嘗試使用if比較它們時,什麼也沒有顯示出來。我做的比較如下:比較jinja2模板中的兩個變量
{% if profile == element.author %}
{{ profile }} and {{ element.author }} are same
{% else %}
{{ profile }} and {{ element.author }} are **not** same
{% endif %}
我得到的輸出test and test are not same
哪些錯誤,我怎麼能比?
嘗試輸入值:{{[profile,element.author]}} – defuz
意外發布。這個表達式應該表示變量。 – defuz