Commit 24a71934 by Timothée Peignier

make css replace use regexp

parent 246b1093
import re
from django.conf import settings
from compress.filter_base import FilterBase
......@@ -5,10 +6,9 @@ from compress.filter_base import FilterBase
CSS_REPLACE = getattr(settings, 'COMPRESS_CSS_URL_REPLACE', [])
class CSSURLReplace(FilterBase):
def filter_css(self, css):
for old, new in CSS_REPLACE.iteritems():
css = css.replace(old, new)
for pattern, repl in CSS_REPLACE.iteritems():
css = re.sub(pattern, repl, css, flags=re.UNICODE | re.IGNORECASE)
if self.verbose:
print 'Replaced "%s" with "%s"' % (old, new)
print 'Replaced "%s" with "%s"' % (pattern, repl)
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