Ejemplo n.º 1
0
class DjangoScssFilter(FilterBase):
    compiler = DjangoScssCompiler()

    def __init__(self,
                 content,
                 attrs=None,
                 filter_type=None,
                 filename=None,
                 **kwargs):
        # It looks like there is a bug in django-compressor because it expects
        # us to accept attrs.
        super(DjangoScssFilter, self).__init__(content, filter_type, filename,
                                               **kwargs)
        try:
            # this is a link tag which means there is an SCSS file being
            # referenced.
            href = attrs['href']
        except KeyError:
            # this is a style tag which means this is inline SCSS.
            self.filename = None
        else:
            self.filename = href.replace(settings.STATIC_URL, '')

    def input(self, **kwargs):
        return self.compiler.compile_string(self.content,
                                            filename=self.filename)
Ejemplo n.º 2
0
 def compiler(self):
     return DjangoScssCompiler(
         namespace=self.namespace
     )
Ejemplo n.º 3
0
class DjangoScssFilter(BaseDjangoScssFilter):
    compiler = DjangoScssCompiler(output_style="compressed",
                                  extensions=(DjangoExtension, ))
Ejemplo n.º 4
0
 def setUp(self):
     self.compiler = DjangoScssCompiler()
     super(CompilerTestMixin, self).setUp()
Ejemplo n.º 5
0
 def compiler(self):
     return DjangoScssCompiler(
         # output_style is 'nested' by default, which is crazy. See:
         # https://github.com/Kronuz/pyScss/issues/243
         output_style='compact',  # or 'compressed'
         namespace=self.namespace)
Ejemplo n.º 6
0
class MyDjangoScssFilter(DjangoScssFilter):
    compiler = DjangoScssCompiler(
        # Example configuration
        output_style='compressed', )