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

Methods

new   render   to_css   to_tree  

Included Modules

Haml::Util

Classes and Modules

Class Sass::Engine::Line

Constants

PROPERTY_CHAR = ?:   The character that begins a CSS property. @private
SCRIPT_CHAR = ?=   The character that designates that a property should be assigned to a SassScript expression. @private
COMMENT_CHAR = ?/   The character that designates the beginning of a comment, either Sass or CSS. @private
SASS_COMMENT_CHAR = ?/   The character that follows the general COMMENT_CHAR and designates a Sass comment, which is not output as a CSS comment. @private
CSS_COMMENT_CHAR = ?*   The character that follows the general COMMENT_CHAR and designates a CSS comment, which is embedded in the CSS document. @private
DIRECTIVE_CHAR = ?@   The character used to denote a compiler directive. @private
ESCAPE_CHAR = ?\\   Designates a non-parsed rule. @private
MIXIN_DEFINITION_CHAR = ?=   Designates block as mixin definition rather than CSS rules to output @private
MIXIN_INCLUDE_CHAR = ?+   Includes named mixin declared using MIXIN_DEFINITION_CHAR @private
PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/   The regex that matches properties of the form `name: prop`. @private
PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/   The regex that matches and extracts data from properties of the form `name: prop`. @private
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/   The regex that matches and extracts data from properties of the form `:name prop`. @private
DEFAULT_OPTIONS = { :style => :nested, :load_paths => ['.'], :cache => true, :cache_location => './.sass-cache', }.freeze   The default options for Sass::Engine.

Public Class methods

@param template [String] The Sass template. @param options [{Symbol => Object}] An options hash;

  see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}

[Source]

     # File lib/sass/engine.rb, line 143
143:     def initialize(template, options={})
144:       @options = DEFAULT_OPTIONS.merge(options.reject {|k, v| v.nil?})
145:       @template = template
146: 
147:       # Support both, because the docs said one and the other actually worked
148:       # for quite a long time.
149:       @options[:line_comments] ||= @options[:line_numbers]
150: 
151:       # Backwards compatibility
152:       @options[:property_syntax] ||= @options[:attribute_syntax]
153:       case @options[:property_syntax]
154:       when :alternate; @options[:property_syntax] = :new
155:       when :normal; @options[:property_syntax] = :old
156:       end
157:     end

Public Instance methods

Render the template to CSS.

@return [String] The CSS @raise [Sass::SyntaxError] if there‘s an error in the document

[Source]

     # File lib/sass/engine.rb, line 163
163:     def render
164:       to_tree.render
165:     end
to_css()

Alias for render

Parses the document into its parse tree.

@return [Sass::Tree::Node] The root of the parse tree. @raise [Sass::SyntaxError] if there‘s an error in the document

[Source]

     # File lib/sass/engine.rb, line 173
173:     def to_tree
174:       root = Tree::Node.new
175:       append_children(root, tree(tabulate(@template)).first, true)
176:       root.options = @options
177:       root
178:     rescue SyntaxError => e; e.add_metadata(@options[:filename], @line)
179:     end

[Validate]