Commit 2c63bfc9 by Mark Sandstrom

Fix PipelineExtension.render_individual_css arguments

CompressedCSSNode.render_individual_css accepts **kwargs but
PipelineExtension.render_individual_css does not. This causes an
error when render_individual_css is called with the (unused) kwarg
'templates'.
parent d1dba257
......@@ -29,6 +29,7 @@ or just made Pipeline more awesome.
* Jared Scott <jscott@convertro.com>
* Kyle MacFarlane <kyle@deletethetrees.com>
* Luke Yu-Po Chen <nuemail@gmail.com>
* Mark Sandstrom <mark@deliciouslynerdy.com>
* Matt Dennewitz <mattdennewitz@gmail.com>
* Max Klymyshyn <klymyshyn@gmail.com>
* Melvin Laplanche <melvin.laplanche+dev@gmail.com>
......
......@@ -46,7 +46,7 @@ class PipelineExtension(CompressedMixin, Extension):
template = self.environment.get_template(template_name)
return template.render(**context)
def render_individual_css(self, package, paths):
def render_individual_css(self, package, paths, **kwargs):
tags = [self.render_css(package, path) for path in paths]
return '\n'.join(tags)
......
......@@ -7,6 +7,8 @@ from django.test import TestCase
from pipeline.jinja2.ext import PipelineExtension
from tests.utils import pipeline_settings
class ExtensionTest(TestCase):
def setUp(self):
......@@ -23,6 +25,13 @@ class ExtensionTest(TestCase):
template = self.env.from_string(u"""{% compressed_css "screen" %}""")
self.assertEqual(u'<link href="/static/screen.css" rel="stylesheet" type="text/css" />', template.render())
def test_package_css_debug(self):
with pipeline_settings(DEBUG=True):
template = self.env.from_string(u"""{% compressed_css "screen" %}""")
self.assertEqual(u'''<link href="/static/pipeline/css/first.css" rel="stylesheet" type="text/css" />
<link href="/static/pipeline/css/second.css" rel="stylesheet" type="text/css" />
<link href="/static/pipeline/css/urls.css" rel="stylesheet" type="text/css" />''', template.render())
def test_package_js(self):
template = self.env.from_string(u"""{% compressed_js "scripts" %}""")
self.assertEqual(u'<script type="text/css" src="/static/scripts.css" charset="utf-8"></script>', template.render())
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.iteritems():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.iteritems():
setattr(settings, name, value)
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