Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug in css.html not defaulting media attribute to 'all'. #685

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ or just made Pipeline more awesome.
* Josh Braegger <[email protected]>
* Joshua Kehn <[email protected]>
* Julien Hartmann <[email protected]>
* Kevin Fox <[email protected]> (@KFoxder)
* Kristian Glass <[email protected]>
* Kyle MacFarlane <[email protected]>
* Leonardo Orozco <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion pipeline/templates/pipeline/css.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<link href="{{ url }}" rel="stylesheet" type="{{ type }}"{% if media %} media="{{ media }}"{% endif %}{% if title %} title="{{ title|default:"all" }}"{% endif %}{% if charset %} charset="{{ charset }}"{% endif %} />
<link href="{{ url }}" rel="stylesheet" type="{{ type }}" media="{{ media|default:"all" }}"{% if title %} title="{{ title }}"{% endif %}{% if charset %} charset="{{ charset }}"{% endif %} />
22 changes: 22 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ def local_path(path):
'pipeline/css/urls.css'
),
'output_filename': 'screen.css'
},
'screen_media': {
'source_filenames': (
'pipeline/css/first.css',
'pipeline/css/second.css',
'pipeline/css/urls.css'
),
'output_filename': 'screen_media.css',
'extra_context': {
'media': 'screen and (min-width:500px)',
},
},
'screen_title': {
'source_filenames': (
'pipeline/css/first.css',
'pipeline/css/second.css',
'pipeline/css/urls.css'
),
'output_filename': 'screen_title.css',
'extra_context': {
'title': 'Default Style',
},
}
},
'JAVASCRIPT': {
Expand Down
12 changes: 10 additions & 2 deletions tests/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ def render_template(self, template):

def test_compressed_empty(self):
rendered = self.render_template(u"""{% load pipeline %}{% stylesheet "unknow" %}""")
self.assertEqual(u"", rendered)
self.assertEqual(u'', rendered)

def test_compressed_css(self):
rendered = self.render_template(u"""{% load pipeline %}{% stylesheet "screen" %}""")
self.assertEqual(u'<link href="/static/screen.css" rel="stylesheet" type="text/css" />', rendered)
self.assertEqual(u'<link href="/static/screen.css" rel="stylesheet" type="text/css" media="all" />', rendered)

def test_compressed_css_media(self):
rendered = self.render_template(u"""{% load pipeline %}{% stylesheet "screen_media" %}""")
self.assertEqual(u'<link href="/static/screen_media.css" rel="stylesheet" type="text/css" media="screen and (min-width:500px)" />', rendered)

def test_compressed_css_title(self):
rendered = self.render_template(u"""{% load pipeline %}{% stylesheet "screen_title" %}""")
self.assertEqual(u'<link href="/static/screen_title.css" rel="stylesheet" type="text/css" media="all" title="Default Style" />', rendered)

def test_compressed_js(self):
rendered = self.render_template(u"""{% load pipeline %}{% javascript "scripts" %}""")
Expand Down