forked from devs/PCv5
scripts: add modules to render helper
This commit is contained in:
parent
0d9ca65238
commit
20524d28c3
|
@ -1,5 +1,6 @@
|
|||
{% for s in scripts %}
|
||||
<script type="text/javascript" src={{url_for('static', filename=s)}}></script>
|
||||
{% endfor %}
|
||||
<script type="text/javascript" src='/v5shoutbox.js'></script>
|
||||
<script type="module" src={{url_for('static', filename='scripts/emoji-picker-element/index.js')}}></script>
|
||||
{% for m in modules %}
|
||||
<script type="module" src={{url_for('static', filename=m)}}></script>
|
||||
{% endfor %}
|
|
@ -1,7 +1,7 @@
|
|||
from flask import render_template
|
||||
from flask_login import current_user
|
||||
|
||||
def render(*args, styles=[], scripts=[], **kwargs):
|
||||
def render(*args, styles=[], scripts=[], modules=[], **kwargs):
|
||||
# Pour jouer sur les feuilles de style ou les scripts :
|
||||
# render('page.html', styles=['-css/form.css', '+css/admin/forms.css'])
|
||||
|
||||
|
@ -29,6 +29,9 @@ def render(*args, styles=[], scripts=[], **kwargs):
|
|||
'scripts/tag_selector.js',
|
||||
'scripts/editor.js',
|
||||
]
|
||||
modules_ = [
|
||||
'scripts/emoji-picker-element/index.js',
|
||||
]
|
||||
|
||||
# Apply theme from user settings
|
||||
theme = current_user.theme if current_user.is_authenticated else ''
|
||||
|
@ -56,4 +59,10 @@ def render(*args, styles=[], scripts=[], **kwargs):
|
|||
if s[0] == '+':
|
||||
scripts_.append(s[1:])
|
||||
|
||||
return render_template(*args, **kwargs, styles=styles_, scripts=scripts_)
|
||||
for m in modules:
|
||||
if m[0] == '-':
|
||||
modules_.remove(m[1:])
|
||||
if m[0] == '+':
|
||||
modules_.append(m[1:])
|
||||
|
||||
return render_template(*args, **kwargs, styles=styles_, scripts=scripts_, modules=modules_)
|
||||
|
|
Loading…
Reference in New Issue