rewrite script and css loading
This commit is contained in:
parent
664e4607ba
commit
4b0af0ae99
@ -1,9 +1,19 @@
|
|||||||
{% if static.scripts.bootstrap %}
|
{% if static.scripts | length >= 1 +%}
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
|
||||||
|
{% for _, script in static.scripts | items %}
|
||||||
|
{# Load scripts at the bottom by default #}
|
||||||
|
{% if not script.place_in_head | default(False) %}
|
||||||
<script
|
<script
|
||||||
src="{{ static.scripts.bootstrap.src | default('') }}"
|
src="{{ script.src }}"
|
||||||
integrity="{{ static.scripts.bootstrap.integrity | default('') }}"
|
{{- 'integrity="' + script.integrity + '"' if script.integrity else omit }}
|
||||||
crossorigin="{{ static.scripts.bootstrap.crossorigin | default('anonymous' if static.scripts.bootstrap.integrity else '') }}"
|
{{- 'crossorigin="' + script.crossorigin + '"' if script.integrity else omit }}
|
||||||
></script>
|
></script>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -48,12 +48,24 @@
|
|||||||
data-bs-theme="{{ css_theme_name | default('auto') }}"
|
data-bs-theme="{{ css_theme_name | default('auto') }}"
|
||||||
>
|
>
|
||||||
<head>
|
<head>
|
||||||
{% if static.scripts.theme %}
|
|
||||||
|
{# Scripts that should be loaded first to avoid flickering (theme, etc) #}
|
||||||
|
{% if static.scripts | length >= 1 %}
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
|
||||||
|
{% for _, script in static.scripts | items %}
|
||||||
|
{# Only load script if it should be in the head #}
|
||||||
|
{% if script.place_in_head | default(False) %}
|
||||||
|
|
||||||
<script
|
<script
|
||||||
src="{{ static.scripts.theme.src | default('') }}"
|
src="{{ script.src }}"
|
||||||
integrity="{{ static.scripts.theme.integrity | default('') }}"
|
{{- 'integrity="' + script.integrity + '"' if script.integrity else omit }}
|
||||||
crossorigin="{{ static.scripts.theme.crossorigin | default('anonymous' if static.scripts.theme.integrity else '') }}"
|
{{- 'crossorigin="' + script.crossorigin + '"' if script.integrity else omit }}
|
||||||
></script>
|
></script>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
@ -92,31 +104,19 @@
|
|||||||
<link rel="icon" href="/docs/5.3/assets/img/favicons/favicon.ico">
|
<link rel="icon" href="/docs/5.3/assets/img/favicons/favicon.ico">
|
||||||
-->
|
-->
|
||||||
|
|
||||||
{% if static.css.bootstrap %}
|
{% if static.css | length >= 1 +%}
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="{{ static.css.bootstrap.src }}"
|
|
||||||
integrity="{{ static.css.bootstrap.integrity | default('') }}"
|
|
||||||
crossorigin="{{ static.css.bootstrap.crossorigin | default('anonymous' if static.css.bootstrap.integrity else '') }}"
|
|
||||||
/>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if static.css.theme %}
|
<!-- CSS -->
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="{{ static.css.theme.src }}"
|
|
||||||
integrity="{{ static.css.theme.integrity | default('') }}"
|
|
||||||
crossorigin="{{ static.css.theme.crossorigin | default('anonymous' if static.css.theme.integrity else '') }}"
|
|
||||||
/>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if static.css.icons %}
|
{% for _, style in static.css | items %}
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="{{ static.css.icons.src }}"
|
href="{{ style.src }}"
|
||||||
integrity="{{ static.css.icons.integrity | default('') }}"
|
{{- 'integrity="' + style.integrity + '"' if style.integrity else omit }}
|
||||||
crossorigin="{{ static.css.icons.crossorigin | default('anonymous' if static.css.icons.integrity else '') }}"
|
{{- 'crossorigin="' + style.crossorigin + '"' if style.integrity else omit }}
|
||||||
/>
|
/>
|
||||||
{% endif %}
|
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
2
test.py
2
test.py
@ -21,7 +21,7 @@ template_vars = {
|
|||||||
"bootstrap": {
|
"bootstrap": {
|
||||||
"src": "./templates/static/bootstrap.bundle.min.js",
|
"src": "./templates/static/bootstrap.bundle.min.js",
|
||||||
},
|
},
|
||||||
"theme": {"src": "./templates/static/color-modes.js"},
|
"theme": {"src": "./templates/static/color-modes.js", "place_in_head": True},
|
||||||
},
|
},
|
||||||
"css": {
|
"css": {
|
||||||
"bootstrap": {"src": "./templates/static/bootstrap.min.css"},
|
"bootstrap": {"src": "./templates/static/bootstrap.min.css"},
|
||||||
|
Loading…
Reference in New Issue
Block a user