#NEWLINE# @ register . function #NEWLINE# def inline_css( bundle , media = False , debug = None ) : #NEWLINE# #INDENT# '\n    If we are in debug mode, just output a single style tag for each css file.\n    If we are not in debug mode, return a style that contains bundle-min.css.\n    Forces a regular css() call for external URLs (no inline allowed).\n\n    Extracted from jingo-minify and re-registered, see:\n    https://github.com/jsocol/jingo-minify/pull/41\n    Added: turns relative links to absolute ones using STATIC_URL.\n    ' #NEWLINE# if ( debug is None ) : #NEWLINE# #INDENT# debug = getattr ( settings , 'TEMPLATE_DEBUG' , False ) #NEWLINE# #UNINDENT# if debug : #NEWLINE# #INDENT# items = [ _get_compiled_css_url ( i ) for i in settings . MINIFY_BUNDLES [ 'css' ] [ bundle ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items = [ ( 'css/%s-min.css' % bundle ) ] #NEWLINE# #UNINDENT# if ( not media ) : #NEWLINE# #INDENT# media = getattr ( settings , 'CSS_MEDIA_DEFAULT' , 'screen,projection,tv' ) #NEWLINE# #UNINDENT# contents = [ ] #NEWLINE# for css in items : #NEWLINE# #INDENT# if is_external ( css ) : #NEWLINE# #INDENT# return _build_html ( [ css ] , ( '<link rel="stylesheet" media="%s" href="%%s" />' % media ) ) #NEWLINE# #UNINDENT# with open ( get_path ( css ) , 'r' ) as f : #NEWLINE# #INDENT# css_content = f . read ( ) #NEWLINE# css_parsed = re . sub ( 'url\\(([^)]*?)\\)' , _relative_to_absolute , css_content ) #NEWLINE# contents . append ( css_parsed ) #NEWLINE# #UNINDENT# #UNINDENT# return _build_html ( contents , ( '<style type="text/css" media="%s">%%s</style>' % media ) )