fix: convert frappe.boot to JSON properly

We have `frappe.as_json` set as the jinja filter for json

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-12-13 11:08:48 +05:30
parent 50020cffda
commit 4509e75179
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
5 changed files with 5 additions and 6 deletions

View file

@ -95,7 +95,7 @@
{% block base_scripts %}
<!-- js should be loaded in body! -->
<script>
frappe.boot = {{ boot }}
frappe.boot = {{ boot | json }}
// for backward compatibility of some libs
frappe.sys_defaults = frappe.boot.sysdefaults;
</script>

View file

@ -163,7 +163,7 @@
{% block script %}
<script>
frappe.boot = {{ boot }};
frappe.boot = {{ boot | json }};
frappe._messages = {{ translated_messages }};
frappe.web_form_doc = {{ web_form_doc | json }};
frappe.reference_doc = {{ reference_doc | json }};

View file

@ -24,7 +24,7 @@
{% block script %}
<script>
frappe.boot = {{ boot }};
frappe.boot = {{ boot | json }};
frappe._messages = {{ translated_messages }};
frappe.web_form_doc = {{ web_form_doc | json }};
</script>

View file

@ -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 }}";

View file

@ -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"),