Class: Sprockets::SassImporter
- Inherits:
-
Sass::Importers::Filesystem
- Object
- Sass::Importers::Filesystem
- Sprockets::SassImporter
- Defined in:
- lib/sass/rails/importer.rb
Constant Summary collapse
- GLOB =
/\*|\[.+\]/
Instance Method Summary collapse
- #each_globbed_file(glob, base_pathname, options) ⇒ Object
- #extensions ⇒ Object
- #find(name, options) ⇒ Object
- #find_relative(name, base, options) ⇒ Object
- #glob_imports(glob, base_pathname, options) ⇒ Object
Instance Method Details
#each_globbed_file(glob, base_pathname, options) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/sass/rails/importer.rb', line 39 def each_globbed_file(glob, base_pathname, ) Dir["#{base_pathname}/#{glob}"].sort.each do |filename| next if filename == [:filename] yield filename if File.directory?(filename) || context.asset_requirable?(filename) end end |
#extensions ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sass/rails/importer.rb', line 10 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 |
#find(name, options) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/sass/rails/importer.rb', line 31 def find(name, ) if name =~ GLOB nil # globs must be relative else engine_from_path(name, root, ) end end |
#find_relative(name, base, options) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/sass/rails/importer.rb', line 23 def find_relative(name, base, ) if name =~ GLOB glob_imports(name, Pathname.new(base), ) else engine_from_path(name, File.dirname(base), ) end end |
#glob_imports(glob, base_pathname, options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sass/rails/importer.rb', line 46 def glob_imports(glob, base_pathname, ) contents = "" each_globbed_file(glob, base_pathname.dirname, ) do |filename| if File.directory?(filename) context.depend_on(filename) elsif context.asset_requirable?(filename) context.depend_on(filename) contents << "@import #{Pathname.new(filename).relative_path_from(base_pathname.dirname).to_s.inspect};\n" end end return nil if contents.empty? Sass::Engine.new(contents, .merge( :filename => base_pathname.to_s, :importer => self, :syntax => :scss )) end |