# module Sass

The module that contains everything Sass-related:

- {Sass::Engine} is the class used to render Sass/SCSS within Ruby code.

- {Sass::Plugin} is interfaces with web frameworks (Rails and Merb in particular).

- {Sass::SyntaxError} is raised when Sass encounters an error.

- {Sass::CSS} handles conversion of CSS to Sass.

Also see the {file:SASS_REFERENCE.md full Sass reference}.

### Constants

Callable

  A Sass mixin or function.

  `name`: `String` : The name of the mixin/function.

  `args`: `Array<(Script::Tree::Node, Script::Tree::Node)>` : The arguments for the mixin/function.

      Each element is a tuple containing the variable node of the argument
      and the parse tree for the default value of the argument.

  `splat`: `Script::Tree::Node?` : The variable node of the splat argument for this callable, or null.

  `environment`: {Sass::Environment} : The environment in which the mixin/function was defined.

      This is captured so that the mixin/function can have access
      to local variables defined in its scope.

  `tree`: `Array<Tree::Node>` : The parse tree for the mixin/function.

  `has_content`: `Boolean` : Whether the callable accepts a content block.

  `type`: `String` : The user-friendly name of the type of the callable.

  `origin`: `Symbol` : From whence comes the callable: `:stylesheet`, `:builtin`, `:css`

      A callable with an origin of `:stylesheet` was defined in the stylesheet itself.
      A callable with an origin of `:builtin` was defined in ruby.
      A callable (function) with an origin of `:css` returns a function call with arguments to CSS.

GENERIC_LOADED
MERB_LOADED
RAILS_LOADED
ROOT_DIR

  The root directory of the Sass source tree. This may be overridden by the package manager if the lib directory is separated from the main source tree. @api public

VERSION

  A string representing the version of Sass. A more fine-grained representation is available from Sass.version. @api public

### Attributes

tests_running[RW]

@private

### Public Class Methods

compile(contents, options = {}) click to toggle source

Compile a Sass or SCSS string to CSS. Defaults to SCSS.

@param contents [String] The contents of the Sass file. @param options [{Symbol => Object}] An options hash;

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

@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`

    # File lib/sass.rb, line 55
    def self.compile(contents, options = {})
      options[:syntax] ||= :scss
      Engine.new(contents, options).to_css
    end

compile_file(filename, *args) click to toggle source

Compile a file on disk to 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`

@overload ::compile_file(filename, options = {})

    Return the compiled CSS rather than writing it to a file.

    @param filename [String] The path to the Sass, SCSS, or CSS file on disk.
    @param options [{Symbol => Object}] An options hash;
      see {file:SASS_REFERENCE.md#Options the Sass options documentation}
    @return [String] The compiled CSS.

@overload ::compile_file(filename, css_filename, options = {})

    Write the compiled CSS to a file.

    @param filename [String] The path to the Sass, SCSS, or CSS file on disk.
    @param options [{Symbol => Object}] An options hash;
      see {file:SASS_REFERENCE.md#Options the Sass options documentation}
    @param css_filename [String] The location to which to write the compiled CSS.

    # File lib/sass.rb, line 82
    def self.compile_file(filename, *args)
      options = args.last.is_a?(Hash) ? args.pop : {}
      css_filename = args.shift
      result = Sass::Engine.for_file(filename, options).render
      if css_filename
        options[:css_filename] ||= css_filename
        open(css_filename, "w") {|css_file| css_file.write(result)}
        nil
      else
        result
      end
    end

load_paths() click to toggle source

The global load paths for Sass files. This is meant for plugins and libraries to register the paths to their Sass stylesheets to that they may be `@imported`. This load path is used by every instance of {Sass::Engine}. They are lower-precedence than any load paths passed in via the {file:SASS_REFERENCE.md#load_paths-option `:load_paths` option}.

If the `SASS_PATH` environment variable is set, the initial value of `load_paths` will be initialized based on that. The variable should be a colon-separated list of path names (semicolon-separated on Windows).

Note that files on the global load path are never compiled to CSS themselves, even if they aren't partials. They exist only to be imported.

@example

    Sass.load_paths << File.dirname(__FILE__ + '/sass')

@return [Array<String, Pathname, Sass::Importers::Base>]

    # File lib/sass.rb, line 37
    def self.load_paths
      @load_paths ||= if ENV['SASS_PATH']
                        ENV['SASS_PATH'].split(Sass::Util.windows? ? ';' : ':')
                      else
                        []
                      end
    end

logger() click to toggle source

    # File lib/sass/logger.rb, line 13
    def logger
      Thread.current[:sass_logger] ||= Sass::Logger::Base.new
    end

logger=(l) click to toggle source

    # File lib/sass/logger.rb, line 9
    def logger=(l)
      Thread.current[:sass_logger] = l
    end