def test_compressed_css(self, pipeline_enabled): """ Verify the behavior of compressed_css, with the pipeline both enabled and disabled. """ with self.settings(PIPELINE_ENABLED=pipeline_enabled): # Verify the default behavior css_include = compressed_css('style-main-v1') self.assertIn(u'lms-main-v1.css', css_include) # Verify that raw keyword causes raw URLs to be emitted css_include = compressed_css('style-main-v1', raw=True) self.assertIn(u'lms-main-v1.css?raw', css_include)
def test_compressed_css(self, pipeline_enabled, mock_staticfiles_lookup): """ Verify the behavior of compressed_css, with the pipeline both enabled and disabled. """ pipeline = settings.PIPELINE.copy() pipeline['PIPELINE_ENABLED'] = pipeline_enabled with self.settings(PIPELINE=pipeline): # Verify the default behavior css_include = compressed_css('style-main-v1') self.assertIn(u'lms-main-v1.css', css_include) # Verify that raw keyword causes raw URLs to be emitted css_include = compressed_css('style-main-v1', raw=True) self.assertIn(u'lms-main-v1.css?raw', css_include)
def render_css(context,group,raw=False): __M_caller = context.caller_stack._push_frame() try: settings = context.get('settings', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n ') rtl_group = '{}-rtl'.format(group) if get_language_bidi() and rtl_group in settings.PIPELINE_CSS: group = rtl_group __M_writer(u'\n\n') if settings.PIPELINE_ENABLED: __M_writer(u' ') __M_writer(filters.decode.utf8(compressed_css(group, raw=raw) )) __M_writer(u'\n') else: for filename in settings.PIPELINE_CSS[group]['source_filenames']: __M_writer(u' <link rel="stylesheet" href="') __M_writer(filters.html_escape(filters.decode.utf8(staticfiles_storage.url(filename.replace('.scss', '.css'))))) __M_writer(filters.html_escape(filters.decode.utf8("?raw" if raw else ""))) __M_writer(u'" type="text/css" media="all" / >\n') return '' finally: context.caller_stack._pop_frame()
def render_css(context,group): __M_caller = context.caller_stack._push_frame() try: settings = context.get('settings', UNDEFINED) __M_writer = context.writer() # SOURCE LINE 13 __M_writer(u'\n') # SOURCE LINE 14 if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: # SOURCE LINE 15 __M_writer(u' ') __M_writer(filters.decode.utf8(compressed_css(group))) __M_writer(u'\n') # SOURCE LINE 16 else: # SOURCE LINE 17 for filename in settings.PIPELINE_CSS[group]['source_filenames']: # SOURCE LINE 18 __M_writer(u' <link rel="stylesheet" href="') __M_writer(filters.decode.utf8(staticfiles_storage.url(filename.replace('.scss', '.css')))) __M_writer(u'" type="text/css" media="all" / >\n') return '' finally: context.caller_stack._pop_frame()