summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Linke <johannes.linke@posteo.de>2019-08-17 22:24:29 +0200
committerJohannes Linke <johannes.linke@posteo.de>2019-08-18 12:06:37 +0200
commit33fa52d38fdc4daefb52cb1ce88ff596ee24009f (patch)
tree5fd783dec75b77400bc8beb85ffad3a7be5a8ff7
parentd2ea4db1e65299d187d4c56d64a58a9f700a6ed6 (diff)
downloaddjango-compressor-33fa52d38fdc4daefb52cb1ce88ff596ee24009f.tar.gz
Make the jinja2 extension not break on OUTPUT_PRELOAD
-rw-r--r--compressor/contrib/jinja2ext.py2
-rw-r--r--compressor/tests/test_base.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/compressor/contrib/jinja2ext.py b/compressor/contrib/jinja2ext.py
index 63c2495..c519ceb 100644
--- a/compressor/contrib/jinja2ext.py
+++ b/compressor/contrib/jinja2ext.py
@@ -49,7 +49,7 @@ class CompressorExtension(compress.CompressorMixin, Extension):
# The file mode optionally accepts a name
if parser.stream.current.type != 'block_end':
namearg = const(parser.parse_expression())
- elif modearg.value == compress.OUTPUT_INLINE:
+ elif modearg.value == compress.OUTPUT_INLINE or modearg.value == compress.OUTPUT_PRELOAD:
pass
else:
raise TemplateSyntaxError(
diff --git a/compressor/tests/test_base.py b/compressor/tests/test_base.py
index 1326c30..7418047 100644
--- a/compressor/tests/test_base.py
+++ b/compressor/tests/test_base.py
@@ -190,6 +190,7 @@ class CompressorTestCase(SimpleTestCase):
self.assertEqual(output, self.css_node.output().strip())
def test_css_preload_output(self):
+ # this needs to have the same hash as in the test above
out = '<link rel="preload" href="/static/CACHE/css/58a8c0714e59.css" as="style" />'
self.assertEqual(out, self.css_node.output(mode="preload"))
@@ -221,6 +222,7 @@ class CompressorTestCase(SimpleTestCase):
self.assertEqual(out, self.js_node.output())
def test_js_preload_output(self):
+ # this needs to have the same hash as in the test above
out = '<link rel="preload" href="/static/CACHE/js/8a0fed36c317.js" as="script" />'
self.assertEqual(out, self.js_node.output(mode="preload"))