Added django-sekizai support in contrib

This commit is contained in:
Saul Shanabrook
2012-11-03 14:40:02 -04:00
parent c46e52a20c
commit 75e7a79421
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
"""
source: https://gist.github.com/1311010
Get django-sekizai, django-compessor (and django-cms) playing nicely together
re: https://github.com/ojii/django-sekizai/issues/4
using: https://github.com/jezdez/django_compressor.git
and: https://github.com/ojii/django-sekizai.git@0.5
"""
from compressor.templatetags.compress import CompressorNode
from django.template.base import Template
def compress(context, data, name):
"""
Data is the string from the template (the list of js files in this case)
Name is either 'js' or 'css' (the sekizai namespace)
We basically just manually pass the string through the {% compress 'js' %} template tag
"""
return CompressorNode(nodelist=Template(data).nodelist, kind=name, mode='file').render(context=context)

22
docs/django-sekizai.txt Normal file
View File

@@ -0,0 +1,22 @@
django-sekizai Support
==============
Django Compressor comes with support for _django-sekizai via an extension.
_django-sekizai provides the ability to include template code, from within
any block, to a parent block. It is primarily used to include js/css from
included templates to the master template.
It requires _django-sekizai to installed. Refer to the _django-sekizai _docs
for how to use ``render_block``
Usage
--------------
.. code-block:: django
{% load sekizai_tags %}
{% render_block "<js/css>" postprocessor "compressor.contrib.sekizai.compress" %}
.. _django-sekizai: https://github.com/ojii/django-sekizai
.. _docs: http://django-sekizai.readthedocs.org/en/latest/

View File

@@ -42,5 +42,6 @@ Contents
remote-storages
behind-the-scenes
jinja2
django-sekizai
contributing
changelog