-
-
Save shauns/3128346 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" %} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment