Skip to content

Commit

Permalink
Moved short-circuit code to Compressor.output method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Apr 8, 2011
1 parent 0aaac83 commit 4a364dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions compressor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def output(self, mode='file', forced=False):
# or just doing nothing, when neither
# compression nor compilation is enabled
return self.content
# Shortcurcuit in case the content is empty.
if not content:
return ''
# Then check for the appropriate output method and call it
output_func = getattr(self, "output_%s" % mode, None)
if callable(output_func):
Expand Down
3 changes: 0 additions & 3 deletions compressor/templatetags/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ def render(self, context, forced=False):
if content:
return content
content = self.nodelist.render(context)
if (not settings.COMPRESS_ENABLED or
not len(content.strip())) and not forced:
return content
compressor = self.compressor_cls(content)
cachekey = self.cache_key(compressor)
output = self.cache_get(cachekey)
Expand Down

0 comments on commit 4a364dc

Please sign in to comment.