Skip to content

Instantly share code, notes, and snippets.

@dfalk
Forked from timmyomahony/postprocess_sekizai.py
Created February 28, 2012 04:43
Show Gist options
  • Save dfalk/1929594 to your computer and use it in GitHub Desktop.
Save dfalk/1929594 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