Permalink
Browse files

[➠] Allow “*.css.sass” or “*.css.scss” as file extensions without hav…

…ing to write “@import "foo.css.scss"”.
  • Loading branch information...
1 parent 7ab685f commit 7df820c2dd45cad830cdd8b94b62dc473a5c3483 Maik Kempe committed Jun 18, 2013
@@ -0,0 +1,20 @@
+require 'sass/importers/filesystem'
+
+module Guard
+ class Sass
+ class Importer < ::Sass::Importers::Filesystem
+ def extensions
+ {
+ 'css' => :scss,
+ 'css.scss' => :scss,
+ 'css.sass' => :sass,
+ 'css.erb' => :scss,
+ 'scss.erb' => :scss,
+ 'sass.erb' => :sass,
+ 'css.scss.erb' => :scss,
+ 'css.sass.erb' => :sass
+ }.merge!(super)
+ end
+ end
+ end
+end
@@ -77,10 +77,11 @@ def compile_files(files)
# @return [String] Compiled css.
def compile(file)
sass_options = {
- :load_paths => options[:load_paths],
- :style => options[:style],
- :debug_info => options[:debug_info],
- :line_numbers => options[:line_numbers]
+ :filesystem_importer => Importer,
+ :load_paths => options[:load_paths],
+ :style => options[:style],
+ :debug_info => options[:debug_info],
+ :line_numbers => options[:line_numbers]
}
::Sass::Engine.for_file(file, sass_options).render
@@ -125,3 +126,5 @@ def write_file(content, dir, file)
end
end
end
+
+require 'guard/sass/importer'
@@ -0,0 +1,2 @@
+# Ignore sass cache
+.sass-cache
View
@@ -1,4 +1,4 @@
-source :rubygems
+source "http://rubygems.org"
group :osx do
gem 'growl'
@@ -8,4 +8,4 @@ end
gem 'compass'
gem 'guard', '>= 1.1.0'
gem 'guard-sass', :path => '../'
-gem 'guard-shell'
+gem 'guard-shell'
@@ -0,0 +1,2 @@
+html
+ color: blue
@@ -1,3 +1,2 @@
html
- color: blue
-
+ color: blue
@@ -10,4 +10,4 @@
.badError {
@extend .error;
border-width: 4px;
-}
+}
@@ -0,0 +1,4 @@
+@import partials/_sass_importer
+
+body
+ background: red
@@ -1,3 +1,2 @@
body
- color: red
-
+ color: red
@@ -0,0 +1,5 @@
+html {
+ color: blue; }
+
+body {
+ background: red; }
@@ -15,7 +15,6 @@
Guard.stub(:listener).and_return stub('Listener')
end
-
describe '#run' do
it 'returns a list of changed files' do
@@ -63,12 +62,13 @@
mock_engine = mock(::Sass::Engine)
::Sass::Engine.should_receive(:new).with('', {
- :load_paths => ['sass'],
- :style => :nested,
- :debug_info => false,
- :line_numbers => false,
- :syntax => :sass,
- :filename => "a.sass"
+ :filesystem_importer => Guard::Sass::Importer,
+ :load_paths => ['sass'],
+ :style => :nested,
+ :debug_info => false,
+ :line_numbers => false,
+ :syntax => :sass,
+ :filename => 'a.sass'
}).and_return(mock_engine)
mock_engine.should_receive(:render)

0 comments on commit 7df820c

Please sign in to comment.