You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by jh...@apache.org on 2021/08/13 18:20:42 UTC
[airflow] 22/38: #16976 Add json.dumps() for templated fields
objects: 'dict' and 'list' (#17082)
This is an automated email from the ASF dual-hosted git repository.
jhtimmins pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit f5ef0dda988bdfef75a396f0cae1b8f7e031818e
Author: Vladimir Aranovsky <66...@users.noreply.github.com>
AuthorDate: Mon Jul 19 22:22:42 2021 +0300
#16976 Add json.dumps() for templated fields objects: 'dict' and 'list' (#17082)
(cherry picked from commit 1a0730a08f2d72cd71447b6d6549ec10d266dd6a)
---
airflow/www/views.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 6b2b2a4..f77e66c 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -972,6 +972,8 @@ class Airflow(AirflowBaseView):
content = getattr(task, template_field)
renderer = task.template_fields_renderers.get(template_field, template_field)
if renderer in renderers:
+ if isinstance(content, (dict, list)):
+ content = json.dumps(content, sort_keys=True, indent=4)
html_dict[template_field] = renderers[renderer](content)
else:
html_dict[template_field] = Markup("<pre><code>{}</pre></code>").format(pformat(content))