Created
October 25, 2011 01:11
-
-
Save timmyomahony/1311010 to your computer and use it in GitHub Desktop.
django-sekizai postprocessor for enabling django-compressor compatibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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/[email protected] | |
""" | |
from compressor.templatetags.compress import CompressorNode | |
from django.template.base import * | |
def compress(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(Template(data).nodelist, name, 'file').render({}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{% render_block "js" postprocessor "postprocess_sekizai.compress" %} | |
... |
andreif
commented
Apr 27, 2012
In the template.html, what should be loaded at the top? I am getting an import error for postprocess_sekizai
This has been included in django-compressor by now, and there's a fix for it to prevent double-rendering: django-compressor/django-compressor#623
Another PR provides the functionality to use several "js" and "css" blocks: django-compressor/django-compressor#622
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment