Esempio n. 1
0
    def compile(self):
        outfile = self.storage.path(self.new_name)

        locations = list(get_base_finders_locations())
        options = (
            '--include-path={0}'.format(':'.join(reversed(locations))),
            '--global-var=\'STATIC_URL="{0}"\''.format(settings.STATIC_URL)
        )

        self.execute_cmd(infile=self.original, outfile=outfile, options=' '.join(options))
        return self.new_name
Esempio n. 2
0
    def compile(self):
        with open(self.original, 'r') as fp:
            contents = 'STATIC_URL = \'{0}\'\n\n{1}'.format(settings.STATIC_URL, fp.read())

        locations = list(get_base_finders_locations())
        locations.insert(0, os.path.dirname(self.original))

        options = ' '.join(['-I {0}'.format(x) for x in locations])

        contents = self.execute_cmd(data=contents, options=options)
        self.save_contents(contents)

        return self.new_name
Esempio n. 3
0
    def compile(self):
        with open(self.original, 'r') as fp:
            contents = smart_str('$STATIC_URL: "{0}";\n\n{1}'.format(
                settings.STATIC_URL, fp.read())
            )

        locations = list(get_base_finders_locations())
        locations.append(os.path.dirname(self.original))
        options = '-I {0}'.format(':'.join(reversed(locations)))

        contents = self.execute_cmd(data=contents, options=options)
        self.save_contents(contents)

        return self.new_name
Esempio n. 4
0
    def compile(self):
        try:
            import sass
        except ImportError:
            raise CompilerError('Unable to import sass module.')

        with open(self.original, 'r') as fp:
            contents = smart_str('$STATIC_URL: "{0}";\n\n{1}'.format(
                settings.STATIC_URL, fp.read())
            )

        locations = list(get_base_finders_locations())
        locations.append(os.path.dirname(self.original))

        contents = sass.compile_string(
            force_bytes(contents),
            include_paths=force_bytes(':'.join(reversed(locations)))
        )

        self.save_contents(contents)

        return self.new_name