Sha256: 6c68ed4e582a72a568e38f1b71b9e62fc18010162a47c5fc2980307f7ebdcc9c
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
# encoding: UTF-8 module Bunch module Compilers class Sass def initialize(file, tree, path) require "sass" @file, @tree, @abs_path = file, tree, path rescue LoadError => e raise "'gem install sass' to compile .sass and .scss files." end def path @file.path.sub(/\.s[ca]ss$/, "") + ".css" end def content new_engine(@file.content, @abs_path).render end def new_engine(content, path) syntax = path.end_with?("scss") ? :scss : :sass ::Sass::Engine.new( content, syntax: syntax, filename: path, importer: self) end ## Sass importer interface ## def find_relative(path, base, options) abs = ::File.expand_path("../#{path}", "/#{base}")[1..-1] find(abs, options) end def find(path, options) path = path.chomp(".scss").chomp(".sass") path_with_underscore = path.sub(/(.*)\//, '\1/_') file = @tree.get_fuzzy(path) || @tree.get_fuzzy(path_with_underscore) if file new_engine(file.content, file.path) else raise "Couldn't find '#{path}' to import! (#{options[:original_filename]}:#{options[:_line]})" end end def mtime(path, options) end def key(path, options) ["Bunch:#{::File.dirname(path)}", ::File.basename(path)] end end end Compiler.register ".sass", Compilers::Sass Compiler.register ".scss", Compilers::Sass end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bunch-1.0.0pre3 | lib/bunch/compilers/sass.rb |
bunch-1.0.0pre2 | lib/bunch/compilers/sass.rb |
bunch-1.0.0pre1 | lib/bunch/compilers/sass.rb |