2016-04-21 08:48:33 +02:00
|
|
|
"""
|
|
|
|
`minified_js` is taken from `zerver.templatetags.minified_js.py`
|
|
|
|
"""
|
|
|
|
|
2016-12-08 05:06:51 +01:00
|
|
|
from typing import Text
|
2016-08-08 10:59:59 +02:00
|
|
|
|
2016-04-21 08:48:33 +02:00
|
|
|
from django.conf import settings
|
|
|
|
from django.template import TemplateSyntaxError
|
|
|
|
|
|
|
|
from zerver.templatetags.minified_js import MinifiedJSNode
|
|
|
|
|
|
|
|
|
2018-04-16 12:29:53 +02:00
|
|
|
def minified_js(sourcefile: str, csp_nonce: str) -> Text:
|
2016-04-21 08:48:33 +02:00
|
|
|
if sourcefile not in settings.JS_SPECS:
|
|
|
|
raise TemplateSyntaxError(
|
|
|
|
"Invalid argument: no JS file %s".format(sourcefile))
|
|
|
|
|
2018-04-16 12:29:53 +02:00
|
|
|
return MinifiedJSNode(sourcefile, csp_nonce).render({})
|