Skip to content

Commit

Permalink
Apply CssAbsoluteFilter to precompiled css even when compression is d…
Browse files Browse the repository at this point in the history
  • Loading branch information
karyon committed Sep 24, 2015
1 parent 52c5a8b commit 6ad81c0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions compressor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from compressor.exceptions import (CompressorError, UncompressableFileError,
FilterDoesNotExist)
from compressor.filters import CachedCompilerFilter
from compressor.filters.css_default import CssAbsoluteFilter
from compressor.storage import compressor_file_storage
from compressor.signals import post_compress
from compressor.utils import get_class, get_mod_func, staticfiles
Expand Down Expand Up @@ -209,20 +210,24 @@ def hunks(self, forced=False):
precompiled, value = self.precompile(value, **options)

if enabled:
yield self.filter(value, **options)
yield self.filter(value, self.cached_filters, **options)
elif precompiled:
# since precompiling moves files around, it breaks url()
# statements in css files. therefore we run the absolute filter
# on precompiled css files even if compression is disabled.
if CssAbsoluteFilter in self.cached_filters:
value = self.filter(value, [CssAbsoluteFilter], **options)
yield self.handle_output(kind, value, forced=True,
basename=basename)
else:
if precompiled:
yield self.handle_output(kind, value, forced=True,
basename=basename)
else:
yield self.parser.elem_str(elem)
yield self.parser.elem_str(elem)

def filter_output(self, content):
"""
Passes the concatenated content to the 'output' methods
of the compressor filters.
"""
return self.filter(content, method=METHOD_OUTPUT)
return self.filter(content, self.cached_filters, method=METHOD_OUTPUT)

def filter_input(self, forced=False):
"""
Expand Down Expand Up @@ -274,8 +279,8 @@ def precompile(self, content, kind=None, elem=None, filename=None,

return False, content

def filter(self, content, method, **kwargs):
for filter_cls in self.cached_filters:
def filter(self, content, filters, method, **kwargs):
for filter_cls in filters:
filter_func = getattr(
filter_cls(content, filter_type=self.type), method)
try:
Expand Down

0 comments on commit 6ad81c0

Please sign in to comment.