aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-07-27 14:29:49 +0200
committerDaniel Schadt <kingdread@gmx.de>2022-07-27 14:29:49 +0200
commitb96bb6edb753dd3bf09436e84e7aa78993dba56a (patch)
tree8789ac4f65058cd5a68641813c05c52699e9702f
parent38f3d67eb385dfb93b1fe9a7301225b1e4993b77 (diff)
downloadfietsboek-b96bb6edb753dd3bf09436e84e7aa78993dba56a.tar.gz
fietsboek-b96bb6edb753dd3bf09436e84e7aa78993dba56a.tar.bz2
fietsboek-b96bb6edb753dd3bf09436e84e7aa78993dba56a.zip
embed JSON strings via tojson
This will properly escape special characters and quotes in the string.
-rw-r--r--fietsboek/templates/layout.jinja210
1 files changed, 5 insertions, 5 deletions
diff --git a/fietsboek/templates/layout.jinja2 b/fietsboek/templates/layout.jinja2
index 984a790..0e43a36 100644
--- a/fietsboek/templates/layout.jinja2
+++ b/fietsboek/templates/layout.jinja2
@@ -19,15 +19,15 @@
<link href="{{request.static_url('fietsboek:static/theme.css')}}" rel="stylesheet">
<script>
-const FRIENDS_URL = "{{ request.route_url('json-friends') }}";
-const LOCALE = "{{ request.localizer.locale_name.replace('_', '-') }}";
+const FRIENDS_URL = {{ request.route_url('json-friends') | tojson }};
+const LOCALE = {{ request.localizer.locale_name.replace('_', '-') | tojson }};
{% if request.registry.settings.get("thunderforest.api_key") %}
{% set api_key = request.registry.settings.get("thunderforest.api_key") %}
window.JB = window.JB || {};
window.JB.GPX2GM = window.JB.GPX2GM || {};
-window.JB.GPX2GM.OSM_Cycle_Api_Key = "{{ api_key }}";
-window.JB.GPX2GM.OSM_Landscape_Api_Key = "{{ api_key }}";
-window.JB.GPX2GM.OSM_Outdoors_Api_Key = "{{ api_key }}";
+window.JB.GPX2GM.OSM_Cycle_Api_Key = {{ api_key | tojson }};
+window.JB.GPX2GM.OSM_Landscape_Api_Key = {{ api_key | tojson}};
+window.JB.GPX2GM.OSM_Outdoors_Api_Key = {{ api_key | tojson }};
{% endif %}
</script>