diff sat_templates/templates/default/base/base.html @ 237:caa3767707fb

base/base.html: expose CSRF token to script + fixed script content
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 17:57:01 +0200
parents 739c3e6999fa
children
line wrap: on
line diff
--- a/sat_templates/templates/default/base/base.html	Fri Jun 19 16:53:20 2020 +0200
+++ b/sat_templates/templates/default/base/base.html	Fri Jun 19 17:57:01 2020 +0200
@@ -57,6 +57,9 @@
     {% endif %}
 
     {# JS handling #}
+    {% if csrf_token is defined %}
+        <script>var csrf_token = "{{csrf_token}}";</script>
+    {% endif %}
     {% if websocket is defined %}
         {{ script.include('websocket', '') }}
     {% endif %}
@@ -64,7 +67,7 @@
     <script>expand_txt="{% trans %}Click to expand…{% endtrans %}"; reduce_txt="{% trans %}Click to reduce…{% endtrans %}";</script>
     {{ script.generate_scripts() }}
     {% for script in scripts %}
-        <script{{ {'src': script.src, 'type': script.type} | xmlattr }}>{{script.content}}</script>
+        <script{{ {'src': script.src, 'type': script.type} | xmlattr }}>{{script.content|safe}}</script>
     {% endfor %}
     {% if websocket is defined %}
         <script>var socket=new WSHandler("{{websocket.url}}", "{{websocket.token}}", {{websocket.debug}});</script>