Mercurial > libervia-web
changeset 1630:1d1b1f360b75
server (pages): fix `expose_to_scripts` by dumping JSON:
For whatever reason `expose_to_scripts` was doing a pseudo python/JS conversion itself and
was only handling correctly `str` and `None`, while what is expected here is a JSON dump.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jun 2025 17:07:55 +0200 |
parents | 961468588131 |
children | d4dd4c94463c |
files | libervia/web/server/pages.py |
diffstat | 1 files changed, 1 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/web/server/pages.py Sun Jun 08 17:29:39 2025 +0200 +++ b/libervia/web/server/pages.py Thu Jun 26 17:07:55 2025 +0200 @@ -588,14 +588,7 @@ template_data = request.template_data scripts = template_data.setdefault("scripts", utils.OrderedSet()) for name, value in kwargs.items(): - if value is None: - value = "null" - elif isinstance(value, str): - # FIXME: workaround for subtype used by python-dbus (dbus.String) - # to be removed when we get rid of python-dbus - value = repr(str(value)) - else: - value = repr(value) + value = json.dumps(value) scripts.add(Script(content=f"var {name}={value};")) def register_uri(self, uri_tuple, get_uri_cb):