Commit 246b1093 by Timothée Peignier

make css url replace more versatile

parent 9662e69f
from django.conf import settings from django.conf import settings
from compress.filter_base import FilterBase, FilterError from compress.filter_base import FilterBase
REPLACE_LIST = getattr(settings, 'COMPRESS_CSS_URL_REPLACE', []) CSS_REPLACE = getattr(settings, 'COMPRESS_CSS_URL_REPLACE', [])
class CSSURLReplace(FilterBase): class CSSURLReplace(FilterBase):
def filter_css(self, css): def filter_css(self, css):
filtered_css = css for old, new in CSS_REPLACE.iteritems():
if type(REPLACE_LIST) == list: css = css.replace(old, new)
for REPLACE in REPLACE_LIST: if self.verbose:
if len(REPLACE) == 2: print 'Replaced "%s" with "%s"' % (old, new)
filtered_css = filtered_css.replace(REPLACE[0], REPLACE[1]) return css
if self.verbose:
print 'Replaced "%s" with "%s"' % REPLACE
return filtered_css
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment