mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
extra_body_script module support, closes #1187
This commit is contained in:
parent
fa0c3777b8
commit
c38c42948c
5 changed files with 31 additions and 9 deletions
|
|
@ -781,7 +781,13 @@ class Datasette:
|
|||
datasette=self,
|
||||
):
|
||||
extra_script = await await_me_maybe(extra_script)
|
||||
body_scripts.append(Markup(extra_script))
|
||||
if isinstance(extra_script, dict):
|
||||
script = extra_script["script"]
|
||||
module = bool(extra_script.get("module"))
|
||||
else:
|
||||
script = extra_script
|
||||
module = False
|
||||
body_scripts.append({"script": Markup(script), "module": module})
|
||||
|
||||
extra_template_vars = {}
|
||||
# pylint: disable=no-member
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
{% include "_close_open_menus.html" %}
|
||||
|
||||
{% for body_script in body_scripts %}
|
||||
<script>{{ body_script }}</script>
|
||||
<script{% if body_script.module %} type="module"{% endif %}>{{ body_script.script }}</script>
|
||||
{% endfor %}
|
||||
|
||||
{% if select_templates %}<!-- Templates considered: {{ select_templates|join(", ") }} -->{% endif %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue