Skip to content

Instantly share code, notes, and snippets.

@elishowk
Forked from timmyomahony/postprocess_sekizai.py
Created February 10, 2012 15:07
Show Gist options
  • Save elishowk/1790157 to your computer and use it in GitHub Desktop.
Save elishowk/1790157 to your computer and use it in GitHub Desktop.
django-sekizai postprocessor for enabling django-compressor compatibility
"""
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 *
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({})
...
{% 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