Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用以下方法在 jinja 中定义了一个变量:
{% set my_var = 10 %}
和一个宏:
{% macro my_function(my_var) %} where my_col > my_var {% endmacro %}
我想在我设置的变量上调用宏以获得字符串:
where my_col > 10
我试过了
{{my_function(my_var)}}
但它不起作用。我不确定是否必须更改呼叫或宏。你知道我怎样才能做到这一点吗?
提前致谢!
函数定义中有一个错误,需要将其定义为:
{% macro my_function(my_var) %} where my_col > {{ my_var }} {% endmacro %}