Flask / Jinja2:宏调用上下文宏

时间:2016-11-25 14:35:53

标签: python flask macros jinja2

我有一个包含一些宏的模板:

{% macro input(id, editable=current_user.is_active) %}
  ... some content ...
{% endmacro %}

{% macro the_form() %}
  {{input('id1')}}
  {{input('id2', False)}}
{% endmacro %}

然后我想在另一个模板中使用这些宏:

{% from 'forms.html' import the_form with context %}

{{ the_form() }}

但我总是收到错误name 'l_current_user' is not defined

为什么l_current_user而不是current_user

如何让嵌套宏访问current_user变量?

0 个答案:

没有答案