ashb commented on a change in pull request #6793: [AIRFLOW-1076] Add get method
for template variable accessor
URL: https://github.com/apache/airflow/pull/6793#discussion_r357109861
##########
File path: docs/macros-ref.rst
##########
@@ -88,7 +88,12 @@ attributes and methods.
The ``var`` template variable allows you to access variables defined in
Airflow's
UI. You can access them as either plain-text or JSON. If you use JSON, you are
also able to walk nested structures, such as dictionaries like:
-``{{ var.json.my_dict_var.key1 }}``
+``{{ var.json.my_dict_var.key1 }}``.
+
+It is also possible to fetch a variable by string if needed with
+``{{ var.value.get('my.var', 'fallback') }}`` or
Review comment:
Instead of needing a code change can we instead use Jinja's built in
`default` fliter? `{{ var.value['my.var'] | default 'fallback' }}`?
https://jinja.palletsprojects.com/en/2.10.x/templates/#default
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services