Skip to content

Commit

Permalink
Switch to sass
Browse files Browse the repository at this point in the history
  • Loading branch information
funkybob committed Mar 6, 2017
1 parent 8dcf316 commit 0cc51b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions graaf/scss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@

import os

from scss import Compiler
import sass

from .base import Generator


class SassGenerator(Generator):
extensions = ['.scss', '.sass']

def __init__(self, include_paths=None, include_source=True, output_style='nested'):
def __init__(self, include_paths=None, include_source=True, minify=True):
self.include_paths = include_paths or []
self.include_source = include_source
self.output_style = output_style
self.minify = minify

def can_process(self, filename):
return super(SassGenerator, self).can_process(filename) and not filename.startswith('_')

def process(self, root, dest_dir, filename, processor):
basename, ext = os.path.splitext(filename)

search_path = self.include_paths
include_paths = self.include_paths
if self.include_source:
search_path.append(processor.srcdir)
compiler = Compiler(search_path=search_path, output_style=self.output_style)
include_paths.append(processor.srcdir)

with open(os.path.join(root, filename)) as fin:
with open(os.path.join(dest_dir, basename + '.css'), 'w') as fout:
fout.write(compiler.compile_string(fin.read()))
fout.write(sass.compile_string(
fin.read(),
include_paths=include_paths[0],
output_style=sass.SASS_STYLE_COMPRESSED if self.minify else sass.SASS_STYLE_NESTED,
))

return True
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'stencil-template',
'Markdown',
'pyyaml',
'pyScss',
'sass',
],
scripts=['scripts/graaf'],
)

0 comments on commit 0cc51b6

Please sign in to comment.