Class | Sass::Engine |
In: |
lib/sass/engine.rb
|
Parent: | Object |
This class handles the parsing and compilation of the Sass template. Example usage:
template = File.load('stylesheets/sassy.sass') sass_engine = Sass::Engine.new(template) output = sass_engine.render puts output
PROPERTY_CHAR | = | ?: | The character that begins a CSS property. | |
COMMENT_CHAR | = | ?/ | The character that designates the beginning of a comment, either Sass or CSS. | |
SASS_COMMENT_CHAR | = | ?/ | The character that follows the general COMMENT_CHAR and designates a Sass comment, which is not output as a CSS comment. | |
SASS_LOUD_COMMENT_CHAR | = | ?! | The character that indicates that a comment allows interpolation and should be preserved even in `:compressed` mode. | |
CSS_COMMENT_CHAR | = | ?* | The character that follows the general COMMENT_CHAR and designates a CSS comment, which is embedded in the CSS document. | |
DIRECTIVE_CHAR | = | ?@ | The character used to denote a compiler directive. | |
ESCAPE_CHAR | = | ?\\ | Designates a non-parsed rule. | |
MIXIN_DEFINITION_CHAR | = | ?= | Designates block as mixin definition rather than CSS rules to output | |
MIXIN_INCLUDE_CHAR | = | ?+ | Includes named mixin declared using MIXIN_DEFINITION_CHAR | |
PROPERTY_OLD | = | /^:([^\s=:"]+)\s*(?:\s+|$)(.*)/ | The regex that matches and extracts data from properties of the form `:name prop`. | |
DEFAULT_OPTIONS | = | { :style => :nested, :load_paths => ['.'], :cache => true, :cache_location => './.sass-cache', :syntax => :sass, :filesystem_importer => Sass::Importers::Filesystem | The default options for Sass::Engine. @api public | |
MIXIN_DEF_RE | = | /^(?:=|@mixin)\s*(#{Sass::SCSS::RX::IDENT})(.*)$/ | ||
CONTENT_RE | = | /^@content\s*(.+)?$/ | ||
MIXIN_INCLUDE_RE | = | /^(?:\+|@include)\s*(#{Sass::SCSS::RX::IDENT})(.*)$/ | ||
FUNCTION_RE | = | /^@function\s*(#{Sass::SCSS::RX::IDENT})(.*)$/ |
Returns the {Sass::Engine} for the given file. This is preferable to Sass::Engine.new when reading from a file because it properly sets up the Engine‘s metadata, enables parse-tree caching, and infers the syntax from the filename.
@param filename [String] The path to the Sass or SCSS file @param options [{Symbol => Object}] The options hash;
See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
@return [Sass::Engine] The Engine for the given Sass or SCSS file. @raise [Sass::SyntaxError] if there‘s an error in the document.
Creates a new Engine. Note that Engine should only be used directly when compiling in-memory Sass code. If you‘re compiling a single Sass file from the filesystem, use \{Sass::Engine.for_file}. If you‘re compiling multiple files from the filesystem, use {Sass::Plugin}.
@param template [String] The Sass template.
This template can be encoded using any encoding that can be converted to Unicode. If the template contains an `@charset` declaration, that overrides the Ruby encoding (see {file:SASS_REFERENCE.md#encodings the encoding documentation})
@param options [{Symbol => Object}] An options hash.
See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
@see {Sass::Engine.for_file} @see {Sass::Plugin}
Converts a Sass options hash into a standard form, filling in default values and resolving aliases.
@param options [{Symbol => Object}] The options hash;
see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}
@return [{Symbol => Object}] The normalized options hash. @private
Gets a set of all the documents that are (transitive) dependencies of this document, not including the document itself.
@return [[Sass::Engine]] The dependency documents.
Render the template to CSS.
@return [String] The CSS @raise [Sass::SyntaxError] if there‘s an error in the document @raise [Encoding::UndefinedConversionError] if the source encoding
cannot be converted to UTF-8
@raise [ArgumentError] if the document uses an unknown encoding with `@charset`
Returns the original encoding of the document, or `nil` under Ruby 1.8.
@return [Encoding, nil] @raise [Encoding::UndefinedConversionError] if the source encoding
cannot be converted to UTF-8
@raise [ArgumentError] if the document uses an unknown encoding with `@charset`
Parses the document into its parse tree. Memoized.
@return [Sass::Tree::Node] The root of the parse tree. @raise [Sass::SyntaxError] if there‘s an error in the document