File tree Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Original file line number Diff line number Diff line change 1+ from django .conf import settings
2+
3+
4+ SETTINGS_KEY = "DJANGO_UNICORN"
5+
6+
7+ def get_settings ():
8+ django_unicorn_settings = {}
9+
10+ if hasattr (settings , SETTINGS_KEY ):
11+ django_unicorn_settings = getattr (settings , SETTINGS_KEY )
12+
13+ return django_unicorn_settings
14+
15+
16+ def get_setting (key , default = None ):
17+ django_unicorn_settings = get_settings ()
18+
19+ return django_unicorn_settings .get (key , default )
Original file line number Diff line number Diff line change 11{% load static %}
22
3- {% if debug %}
4- < script type ="module ">
5- import * as Unicorn from "{% static 'js/unicorn.js' %}" ;
6-
7- // Set Unicorn to the global so it can be used by components
8- window . Unicorn = Unicorn ;
3+ {% if MINIFIED %}
4+ < script src ="{% static 'js/unicorn.min.js' %} "> </ script >
95
6+ < script >
107 var url = "{% url 'django_unicorn:message' %}" ;
118 Unicorn . init ( url ) ;
129</ script >
1310{% else %}
14- < script src ="{% static 'js/unicorn.min.js' %} "> </ script >
11+ < script type ="module ">
12+ import * as Unicorn from "{% static 'js/unicorn.js' %}" ;
13+
14+ // Set Unicorn to the global so it can be used by components
15+ window . Unicorn = Unicorn ;
1516
16- < script >
1717 var url = "{% url 'django_unicorn:message' %}" ;
1818 Unicorn . init ( url ) ;
1919</ script >
Original file line number Diff line number Diff line change 22from django .conf import settings
33
44from ..components import UnicornView
5+ from ..settings import get_setting
56
67
78register = template .Library ()
89
910
1011@register .inclusion_tag ("unicorn/scripts.html" )
1112def unicorn_scripts ():
12- return {"debug " : settings .DEBUG }
13+ return {"MINIFIED " : get_setting ( "MINIFIED" , not settings .DEBUG ) }
1314
1415
1516@register .inclusion_tag ("unicorn/errors.html" , takes_context = True )
You can’t perform that action at this time.
0 commit comments