Pass the compressor class as the sender to the post_compress signal, not the rather generic string named 'django-compressor'.
This commit is contained in:
@@ -266,6 +266,7 @@ class Compressor(object):
|
|||||||
self.context['compressed'].update(context or {})
|
self.context['compressed'].update(context or {})
|
||||||
self.context['compressed'].update(self.extra_context)
|
self.context['compressed'].update(self.extra_context)
|
||||||
final_context = Context(self.context)
|
final_context = Context(self.context)
|
||||||
|
post_compress.send(sender=self.__class__, type=self.type,
|
||||||
mode=mode, context=final_context)
|
mode=mode, context=final_context)
|
||||||
return render_to_string("compressor/%s_%s.html" %
|
return render_to_string("compressor/%s_%s.html" %
|
||||||
(self.type, mode), final_context)
|
(self.type, mode), final_context)
|
||||||
|
@@ -38,6 +38,10 @@ v1.2.0
|
|||||||
if the YUI compressor is shipped as a script like
|
if the YUI compressor is shipped as a script like
|
||||||
``/usr/bin/yui-compressor``.
|
``/usr/bin/yui-compressor``.
|
||||||
|
|
||||||
|
- Changed the sender parameter of the :func:`~compressor.signals.post_compress`
|
||||||
|
signal to be either :class:`compressor.css.CssCompressor` or
|
||||||
|
:class:`compressor.js.JsCompressor` for easier customization.
|
||||||
|
|
||||||
v1.1.1
|
v1.1.1
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@@ -165,7 +165,14 @@ you need the exact filenames for use in an HTML5 manifest file. The signal
|
|||||||
sends the following arguments:
|
sends the following arguments:
|
||||||
|
|
||||||
``sender``
|
``sender``
|
||||||
Always "django-compressor".
|
Either :class:`compressor.css.CssCompressor` or
|
||||||
|
:class:`compressor.js.JsCompressor`.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.2
|
||||||
|
|
||||||
|
The sender is now one of the supported Compressor classes for
|
||||||
|
easier limitation to only one of them, previously it was a string
|
||||||
|
named ``'django-compressor'``.
|
||||||
|
|
||||||
``type``
|
``type``
|
||||||
Either "``js``" or "``css``".
|
Either "``js``" or "``css``".
|
||||||
@@ -177,21 +184,23 @@ sends the following arguments:
|
|||||||
The context dictionary used to render the output of the compress template
|
The context dictionary used to render the output of the compress template
|
||||||
tag.
|
tag.
|
||||||
|
|
||||||
If ``mode`` is "``file``", this will contain a "``url``" key that maps to
|
If ``mode`` is "``file``" the dictionary named ``compressed`` in the
|
||||||
the relative URL for the compressed asset.
|
context will contain a "``url``" key that maps to the relative URL for
|
||||||
|
the compressed asset.
|
||||||
|
|
||||||
If ``type`` is "``css``", the context will additionally contain a
|
If ``type`` is "``css``", the dictionary named ``compressed`` in the
|
||||||
"``media``" key with a value of ``None`` if no media attribute is specified on
|
context will additionally contain a "``media``" key with a value of
|
||||||
the link/style tag and equal to that attribute if one is specified.
|
``None`` if no media attribute is specified on the link/style tag and
|
||||||
|
equal to that attribute if one is specified.
|
||||||
|
|
||||||
Additionally, ``context['name']`` will be the third positional argument to
|
Additionally, ``context['compressed']['name']`` will be the third
|
||||||
the template tag, if provided.
|
positional argument to the template tag, if provided.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
When compressing CSS, the ``post_compress`` signal will be called once for
|
When compressing CSS, the ``post_compress`` signal will be called once for
|
||||||
every different media attribute on the tags within the ``{% compress %}`` tag
|
every different media attribute on the tags within the ``{% compress %}``
|
||||||
in question.
|
tag in question.
|
||||||
|
|
||||||
CSS Notes
|
CSS Notes
|
||||||
---------
|
---------
|
||||||
|
@@ -34,7 +34,7 @@ class PostCompressSignalTestCase(TestCase):
|
|||||||
post_compress.connect(callback)
|
post_compress.connect(callback)
|
||||||
self.js_node.output()
|
self.js_node.output()
|
||||||
args, kwargs = callback.call_args
|
args, kwargs = callback.call_args
|
||||||
self.assertEquals('django-compressor', kwargs['sender'])
|
self.assertEquals(JsCompressor, kwargs['sender'])
|
||||||
self.assertEquals('js', kwargs['type'])
|
self.assertEquals('js', kwargs['type'])
|
||||||
self.assertEquals('file', kwargs['mode'])
|
self.assertEquals('file', kwargs['mode'])
|
||||||
context = kwargs['context']
|
context = kwargs['context']
|
||||||
@@ -47,7 +47,7 @@ class PostCompressSignalTestCase(TestCase):
|
|||||||
post_compress.connect(callback)
|
post_compress.connect(callback)
|
||||||
self.css_node.output()
|
self.css_node.output()
|
||||||
args, kwargs = callback.call_args
|
args, kwargs = callback.call_args
|
||||||
self.assertEquals('django-compressor', kwargs['sender'])
|
self.assertEquals(CssCompressor, kwargs['sender'])
|
||||||
self.assertEquals('css', kwargs['type'])
|
self.assertEquals('css', kwargs['type'])
|
||||||
self.assertEquals('file', kwargs['mode'])
|
self.assertEquals('file', kwargs['mode'])
|
||||||
context = kwargs['context']
|
context = kwargs['context']
|
||||||
|
Reference in New Issue
Block a user