Added docs for new feature.

This commit is contained in:
Jonathan Lukens
2011-08-25 15:19:23 -04:00
parent 05cbb35a54
commit 5ec59839c9

View File

@@ -6,7 +6,7 @@ Usage
.. code-block:: django
{% load compress %}
{% compress <js/css> [<file/infile>] %}
{% compress <js/css> [<file/infile> [block_name]] %}
<html of inline or linked JS/CSS>
{% endcompress %}
@@ -85,10 +85,15 @@ would be rendered something like::
obj.value = "value";
</script>
The compress template tag also supports a third argument for naming the output
of that particular compress tag. This is then passed as an argument to the
`post_compress signal <signals>`.
.. _memcached: http://memcached.org/
.. _caching documentation: http://docs.djangoproject.com/en/1.2/topics/cache/#memcached
.. _pre-compression:
.. _signals:
Pre-compression
---------------
@@ -140,6 +145,44 @@ for the number of seconds defined in the
.. _TEMPLATE_LOADERS: http://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
Signals
-------
.. attribute:: compressor.signals.post_compress
:module:
Django Compressor includes a ``post_compress`` signal that enables you to
listen for changes to your compressed CSS/JS. This is useful, for example, if
you need the exact filenames for use in an HTML5 manifest file. The signal
sends the following arguments:
``sender``
Always "django-compressor".
``name``
The value provided in the 3rd positional argument to the template tag, or
``None`` if no 3rd positional argument was provided.
``type``
Either "``js``" or "``css``".
``mode``
Either "``file``" or "``inline``".
``context``
The context dictionary used to render the output of the compress template
tag. If ``mode`` is "``file``", this 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 "``media``" key with a value of ``None`` if
no media attribute is specified on the link/style tag and equal to that
attribute if one is specified.
.. note::
When compressing CSS, the ``post_compress`` signal will be called once for
every different media attribute on the tags within the ``{% compress %}`` tag
in question.
CSS Notes
---------