module Sass

We keep configuration in its own self-contained file so that we can load it independently in Rails 3, where the full plugin stuff is lazy-loaded.

The module that contains everything Sass-related:

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<(String, Script::Node)>` : The arguments for the mixin/function.

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

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

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

logger[RW]

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#sass_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 30
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.

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

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

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

@return [String] The compiled CSS.

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

Write the compiled CSS to a file.

@param css_filename [String] The location to which to write the compiled CSS.
# File lib/sass.rb, line 54
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