lib/sprockets/sass/importer.rb in sprockets-sass-0.3.0 vs lib/sprockets/sass/importer.rb in sprockets-sass-0.4.0

- old
+ new

@@ -79,30 +79,31 @@ # Finds an asset from the given path. This is where # we make Sprockets behave like Sass, and import partial # style paths. def resolve(path) - path = Pathname.new(path) unless path.is_a?(Pathname) - partial = path.dirname.join("_#{path.basename}") + path = Pathname.new(path) unless path.is_a?(Pathname) - resolve_path(path) || resolve_path(partial) + # First look for the normal path + context.resolve(path) { |found| return found } + + # Then look for the partial-style version + unless path.basename.to_s =~ /^_/ + partial = path.dirname.join "_#{path.basename}" + context.resolve(partial) { |found| return found } + end + + nil end # Finds all of the assets using the given glob. def resolve_glob(glob, base_path) base_path = Pathname.new(base_path) path_with_glob = base_path.dirname.join(glob).to_s Pathname.glob(path_with_glob).sort.select do |path| path != context.pathname && context.asset_requirable?(path) end - end - - # Finds the asset using the context from Sprockets. - def resolve_path(path) - context.resolve path, :content_type => :self - rescue ::Sprockets::FileNotFound, ::Sprockets::ContentTypeMismatch - nil end # Returns the Sass syntax of the given path. def syntax(path) path.to_s.include?(".sass") ? :sass : :scss