from django import template
import re

register = template.Library()

@register.filter
def escape_css_content(value):
    return re.sub(r'''['"\n\\]''', lambda m: '\{:06X}'.format(ord(m.group())), value)
