[英]Jinja2 templating - comparing strings
"{{ 'a+rwx' if '{{ item }}' == '{{ airflow_dag_folder }}' else 'u+rwx,g+rx,o+rx' }}"
這是我要比較的,但是它總是返回u + rwx,g + rx,o + rx。 希望當它們匹配時返回a + rwx,但是即使item與airflow_dag_folder相同,它也不會返回正確的東西。
您正在使用Jinja2表達式。 Jinja2表達式中的變量按其名稱(不帶引號)引用。
在表達式中,您正在將字符串{{ item }}
與字符串{{ airflow_dag_folder }}
。 這兩個字符串不相等,因此您始終會獲得else語句中定義的值。
而是使用:
"{{ 'a+rwx' if item == airflow_dag_folder else 'u+rwx,g+rx,o+rx' }}"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.