Commit 88c6f1c4 by Timothée Peignier

Merge pull request #315 from philwo/fix-templates

Fix whitespace in script tags, remove charset attribute for inline scripts
parents 04e7c8c6 ffd8d9f9
......@@ -51,6 +51,7 @@ or just made Pipeline more awesome.
* Miroslav Shubernetskiy <miroslav@miki725.com>
* Patrick Altman <paltman@gmail.com>
* Peter Baumgartner <pete@lincolnloop.com>
* Philipp Wollermann <philipp.wollermann@gmail.com>
* Pierre Drescher <pierre.drescher@gmail.com>
* Rajiv Bose <nerd.bose@gmail.com>
* Rami Chowdhury <rami.chowdhury@gmail.com>
......
<script {% if async %}async{% endif %} {% if defer %}defer{% endif %} type="text/javascript" charset="utf-8">
<script{% if async %} async{% endif %}{% if defer %} defer{% endif %} type="text/javascript">
{{ source|safe }}
</script>
\ No newline at end of file
<script {% if async %}async{% endif %} {% if defer %}defer{% endif %} type="text/javascript" charset="utf-8">
<script{% if async %} async{% endif %}{% if defer %} defer{% endif %} type="text/javascript">
{{ source|safe }}
</script>
<script {% if async %}async{% endif %} {% if defer %}defer{% endif %} type="{{ type }}" src="{{ url }}" charset="utf-8"></script>
\ No newline at end of file
<script{% if async %} async{% endif %}{% if defer %} defer{% endif %} type="{{ type }}" src="{{ url }}" charset="utf-8"></script>
\ No newline at end of file
<script {% if async %}async{% endif %} {% if defer %}defer{% endif %} type="{{ type }}" src="{{ url }}" charset="utf-8"></script>
<script{% if async %} async{% endif %}{% if defer %} defer{% endif %} type="{{ type }}" src="{{ url }}" charset="utf-8"></script>
......@@ -65,5 +65,42 @@ PIPELINE_JS = {
'pipeline/templates/**/*.jst'
),
'output_filename': 'scripts.js'
},
'scripts_async': {
'source_filenames': (
'pipeline/js/first.js',
'pipeline/js/second.js',
'pipeline/js/application.js',
'pipeline/templates/**/*.jst'
),
'output_filename': 'scripts_async.js',
'extra_context': {
'async': True,
}
},
'scripts_defer': {
'source_filenames': (
'pipeline/js/first.js',
'pipeline/js/second.js',
'pipeline/js/application.js',
'pipeline/templates/**/*.jst'
),
'output_filename': 'scripts_defer.js',
'extra_context': {
'defer': True,
}
},
'scripts_async_defer': {
'source_filenames': (
'pipeline/js/first.js',
'pipeline/js/second.js',
'pipeline/js/application.js',
'pipeline/templates/**/*.jst'
),
'output_filename': 'scripts_async_defer.js',
'extra_context': {
'async': True,
'defer': True,
}
}
}
......@@ -35,7 +35,19 @@ class JinjaTest(TestCase):
def test_package_js(self):
template = self.env.from_string(u"""{% compressed_js "scripts" %}""")
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', template.render())
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', template.render())
def test_package_js_async(self):
template = self.env.from_string(u"""{% compressed_js "scripts_async" %}""")
self.assertEqual(u'<script async type="text/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', template.render())
def test_package_js_defer(self):
template = self.env.from_string(u"""{% compressed_js "scripts_defer" %}""")
self.assertEqual(u'<script defer type="text/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', template.render())
def test_package_js_async_defer(self):
template = self.env.from_string(u"""{% compressed_js "scripts_async_defer" %}""")
self.assertEqual(u'<script async defer type="text/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', template.render())
class DjangoTest(TestCase):
......@@ -52,4 +64,16 @@ class DjangoTest(TestCase):
def test_compressed_js(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts" %}""")
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', rendered)
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', rendered)
def test_compressed_js_async(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async" %}""")
self.assertEqual(u'<script async type="text/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', rendered)
def test_compressed_js_defer(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_defer" %}""")
self.assertEqual(u'<script defer type="text/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', rendered)
def test_compressed_js_async_defer(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async_defer" %}""")
self.assertEqual(u'<script async defer type="text/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', rendered)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment