From 4509e75179889024e08eb6b013064cfc6040b195 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Fri, 13 Dec 2024 11:08:48 +0530 Subject: [PATCH] fix: convert frappe.boot to JSON properly We have `frappe.as_json` set as the jinja filter for json Signed-off-by: Akhil Narang --- frappe/templates/base.html | 2 +- frappe/website/doctype/web_form/templates/web_form.html | 2 +- frappe/website/doctype/web_form/templates/web_list.html | 2 +- frappe/www/app.html | 2 +- frappe/www/app.py | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frappe/templates/base.html b/frappe/templates/base.html index e40305accd..02753571b1 100644 --- a/frappe/templates/base.html +++ b/frappe/templates/base.html @@ -95,7 +95,7 @@ {% block base_scripts %} diff --git a/frappe/website/doctype/web_form/templates/web_form.html b/frappe/website/doctype/web_form/templates/web_form.html index 5b92ed6bcf..123f1252da 100644 --- a/frappe/website/doctype/web_form/templates/web_form.html +++ b/frappe/website/doctype/web_form/templates/web_form.html @@ -163,7 +163,7 @@ {% block script %} diff --git a/frappe/www/app.html b/frappe/www/app.html index d9534be770..4f6d64ec4c 100644 --- a/frappe/www/app.html +++ b/frappe/www/app.html @@ -51,7 +51,7 @@ if (!window.frappe) window.frappe = {}; - frappe.boot = JSON.parse({{ boot }}); + frappe.boot = {{ boot | json }}; frappe._messages = frappe.boot["__messages"]; frappe.csrf_token = "{{ csrf_token }}"; diff --git a/frappe/www/app.py b/frappe/www/app.py index 5f27c0cf01..b347872c84 100644 --- a/frappe/www/app.py +++ b/frappe/www/app.py @@ -43,7 +43,6 @@ def get_context(context): # TODO: Find better fix boot_json = CLOSING_SCRIPT_TAG_PATTERN.sub("", boot_json) - boot_json = json.dumps(boot_json) hooks = frappe.get_hooks() app_include_js = hooks.get("app_include_js", []) + frappe.conf.get("app_include_js", []) @@ -63,7 +62,7 @@ def get_context(context): "layout_direction": "rtl" if is_rtl() else "ltr", "lang": frappe.local.lang, "sounds": hooks["sounds"], - "boot": boot if context.get("for_mobile") else boot_json, + "boot": boot if context.get("for_mobile") else json.loads(boot_json), "desk_theme": boot.get("desk_theme") or "Light", "csrf_token": csrf_token, "google_analytics_id": frappe.conf.get("google_analytics_id"),