Skip to content

Instantly share code, notes, and snippets.

@heynemann
Created April 25, 2012 22:23
Show Gist options
  • Save heynemann/2493973 to your computer and use it in GitHub Desktop.
Save heynemann/2493973 to your computer and use it in GitHub Desktop.
def render(self, context):
content = self.nodelist.render(context)
if not settings.COMPRESS or not len(content.strip()):
return content
if self.kind == 'css':
compressor = CssCompressor(content)
if self.kind == 'js':
compressor = JsCompressor(content)
cachekey = "%s-%s" % (compressor.cachekey, self.mode)
output = self.cache_get(cachekey)
if output is None:
try:
if self.mode == OUTPUT_FILE:
output = compressor.output()
else:
output = compressor.output_inline()
self.cache_set(cachekey, output)
except:
from traceback import format_exc
raise Exception(format_exc())
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment