How can I add new keys to the context that is provided for templates (i.e. Macro)? I have looked in the source code for solution, but could not find out myself.
I have to adapt to external constraints in naming the template parameters (start_date
and end_date
). user_defined_macros
and user_defined_filters
and plugin macros are not applicable, because these will provide functions, not the evaluated values to be substituted (i.e {{start_date()}}
instead of {{start_date}}
must be written in the template).
I have tried to use Jinja's contextfunction
decorator, but context can't be modified.
The get_template_context()
method of TaskInstance
class returns the dictionary in models/taskinstance.py, which becomes the context for templating. It seems that, there's no way to extend (update()) this dictionary by other means other than patching the source of Airflow, which I would like to avoid.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…