Mercurial > libervia-web
changeset 1304:70e3341d25bf
pages: take care of None/null when exposing a variable
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 16 Jul 2020 09:08:50 +0200 |
parents | a48fe20f60c7 |
children | db9ea167c409 |
files | libervia/server/pages.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/server/pages.py Thu Jul 16 09:08:50 2020 +0200 +++ b/libervia/server/pages.py Thu Jul 16 09:08:50 2020 +0200 @@ -554,7 +554,11 @@ template_data = request.template_data scripts = template_data.setdefault("scripts", utils.OrderedSet()) for name, value in kwargs.items(): - scripts.add(Script(content=f"var {name}={value!r};")) + if value is None: + value = "null" + else: + value = repr(value) + scripts.add(Script(content=f"var {name}={value};")) def registerURI(self, uri_tuple, get_uri_cb): """Register a URI handler