Commit 246b1093 by Timothée Peignier

make css url replace more versatile

parent 9662e69f
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):
def filter_css(self, css):
filtered_css = css
if type(REPLACE_LIST) == list:
for REPLACE in REPLACE_LIST:
if len(REPLACE) == 2:
filtered_css = filtered_css.replace(REPLACE[0], REPLACE[1])
if self.verbose:
print 'Replaced "%s" with "%s"' % REPLACE
return filtered_css
\ No newline at end of file
for old, new in CSS_REPLACE.iteritems():
css = css.replace(old, new)
if self.verbose:
print 'Replaced "%s" with "%s"' % (old, new)
return css
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