### Home Classes Methods

### In Files

- lib/sass/importers/base.rb

### Parent

Object

### Methods

- #find
- #find_relative
- #key
- #mtime
- #to_s

### Class/Module Index

Quicksearch

- Sass
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Generic
- Sass::Exec::Sass
- Sass::Exec::SassConvert
- Sass::Exec::Scss
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::ArgList
- Sass::Script::Bool
- Sass::Script::Color
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Interpolation
- Sass::Script::Lexer
- Sass::Script::List
- Sass::Script::Literal
- Sass::Script::Node
- Sass::Script::Null
- Sass::Script::Number
- Sass::Script::Operation
- Sass::Script::Parser
- Sass::Script::String
- Sass::Script::StringInterpolation
- Sass::Script::UnaryOperation
- Sass::Script::Variable
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Interpolation
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::SelectorPseudoClass
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::Shared
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::MultibyteStringScanner
- Sass::Util::StaticConditionalContext
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object

No matching classes.

# Sass::Importers::Base

The abstract base class for Sass importers. All importers should inherit from this.

At the most basic level, an importer is given a string and must return a {Sass::Engine} containing some Sass code. This string can be interpreted however the importer wants; however, subclasses are encouraged to use the URI format for pathnames.

Importers that have some notion of "relative imports" should take a single load path in their constructor, and interpret paths as relative to that. They should also implement the {#find_relative} method.

Importers should be serializable via `Marshal.dump`. In addition to the standard `_dump` and `_load` methods, importers can define `_before_dump`, `_after_dump`, `_around_dump`, and `_after_load` methods as per {Sass::Util#dump} and {Sass::Util#load}.

@abstract

### Public Instance Methods

find(uri, options) click to toggle source

Find a Sass file, if it exists.

This is the primary entry point of the Importer. It corresponds directly to an `@import` statement in Sass. It should do three basic things:

- Determine if the URI is in this importer's format. If not, return nil.

- Determine if the file indicated by the URI actually exists and is readable. If not, return nil.

- Read the file and place the contents in a {Sass::Engine}. Return that engine.

If this importer's format allows for file extensions, it should treat them the same way as the default {Filesystem} importer. If the URI explicitly has a `.sass` or `.scss` filename, the importer should look for that exact file and import it as the syntax indicated. If it doesn't exist, the importer should return nil.

If the URI doesn't have either of these extensions, the importer should look for files with the extensions. If no such files exist, it should return nil.

The {Sass::Engine} to be returned should be passed `options`, with a few modifications. `:syntax` should be set appropriately, `:filename` should be set to `uri`, and `:importer` should be set to this importer.

@param uri [String] The URI to import. @param options [{Symbol => Object}] Options for the Sass file

    containing the `@import` that's currently being resolved.
    This is safe for subclasses to modify destructively.
    Callers should only pass in a value they don't mind being destructively modified.

@return [Sass::Engine, nil] An Engine containing the imported file,

    or nil if it couldn't be found or was in the wrong format.

    # File lib/sass/importers/base.rb, line 86
    def find(uri, options)
      Sass::Util.abstract(self)
    end

find_relative(uri, base, options) click to toggle source

Find a Sass file relative to another file. Importers without a notion of "relative paths" should just return nil here.

If the importer does have a notion of "relative paths", it should ignore its load path during this method.

See {#find} for important information on how this method should behave.

The `:filename` option passed to the returned {Sass::Engine} should be of a format that could be passed to {#find}.

@param uri [String] The URI to import. This is not necessarily relative,

    but this method should only return true if it is.

@param base [String] The base filename. If `uri` is relative,

    it should be interpreted as relative to `base`.
    `base` is guaranteed to be in a format importable by this importer.

@param options [{Symbol => Object}] Options for the Sass file

    containing the `@import` that's currently being resolved.

@return [Sass::Engine, nil] An Engine containing the imported file,

    or nil if it couldn't be found or was in the wrong format.

    # File lib/sass/importers/base.rb, line 46
    def find_relative(uri, base, options)
      Sass::Util.abstract(self)
    end

key(uri, options) click to toggle source

Get the cache key pair for the given Sass URI. The URI need not be checked for validity.

The only strict requirement is that the returned pair of strings uniquely identify the file at the given URI. However, the first component generally corresponds roughly to the directory, and the second to the basename, of the URI.

Note that keys must be unique *across importers*. Thus it's probably a good idea to include the importer name at the beginning of the first component.

@param uri [String] A URI known to be valid for this importer. @param options [{Symbol => Object}] Options for the Sass file

    containing the `@import` currently being checked.

@return [(String, String)] The key pair which uniquely identifies

    the file at the given URI.

    # File lib/sass/importers/base.rb, line 121
    def key(uri, options)
      Sass::Util.abstract(self)
    end

mtime(uri, options) click to toggle source

Returns the time the given Sass file was last modified.

If the given file has been deleted or the time can't be accessed for some other reason, this should return nil.

@param uri [String] The URI of the file to check.

    Comes from a `:filename` option set on an engine returned by this importer.

@param options [{Symbol => Objet}] Options for the Sass file

    containing the `@import` currently being checked.

@return [Time, nil]

    # File lib/sass/importers/base.rb, line 100
    def mtime(uri, options)
      Sass::Util.abstract(self)
    end

to_s() click to toggle source

A string representation of the importer. Should be overridden by subclasses.

This is used to help debugging, and should usually just show the load path encapsulated by this importer.

@return [String]

    # File lib/sass/importers/base.rb, line 132
    def to_s
      Sass::Util.abstract(self)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.