Module: Sass

Extended by:
Features, Version
Defined in:
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/cache_stores.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/cache_stores/base.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/cache_stores/chain.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/cache_stores/filesystem.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/cache_stores/memory.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/cache_stores/null.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/callbacks.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/css.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/engine.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/environment.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/error.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/exec.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/features.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/importers.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/importers/base.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/importers/deprecated_path.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/importers/filesystem.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/logger.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/logger/log_level.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/plugin.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/plugin/configuration.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/plugin/rack.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/plugin/staleness_checker.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/repl.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/root.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/css_lexer.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/css_parser.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/css_variable_warning.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/lexer.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/parser.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/scss.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/scss/css_parser.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/scss/parser.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/scss/rx.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/scss/static_parser.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/abstract_sequence.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/comma_sequence.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/pseudo.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/sequence.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/simple.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/selector/simple_sequence.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/shared.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/stack.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/content_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/debug_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/error_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/function_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/import_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/mixin_def_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/return_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/root_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/variable_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/warn_node.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/cross_platform_random.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/normalized_map.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/subset_map.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/test.rb,
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/version.rb

Overview

The module that contains everything Sass-related:

  • Engine is the class used to render Sass/SCSS within Ruby code.
  • Plugin is interfaces with web frameworks (Rails and Merb in particular).
  • SyntaxError is raised when Sass encounters an error.
  • CSS handles conversion of CSS to Sass.

Also see the full Sass reference.

Defined Under Namespace

Modules: CacheStores, Callbacks, Exec, Features, Importers, Logger, Media, Plugin, SCSS, Script, Selector, Shared, Source, Supports, Tree, Util, Version Classes: BaseEnvironment, CSS, Callable, Engine, Environment, ReadOnlyEnvironment, Repl, SemiGlobalEnvironment, Stack, SyntaxError, UnitConversionError

Constant Summary

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.

File.expand_path(File.join(__FILE__, "../../.."))

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Methods included from Version

version

Methods included from Features

add_feature, has_feature?

Class Attribute Details

+ logger

Returns the value of attribute logger



8
9
10
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/logger.rb', line 8

def logger
  @logger
end

Class Method Details

+ compile(contents, options = {})

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

Parameters:

  • contents (String)

    The contents of the Sass file.

  • options ({Symbol => Object}) (defaults to: {})

    An options hash; see the Sass options documentation

Raises:

  • (Sass::SyntaxError)

    if there’s an error in the document

  • (Encoding::UndefinedConversionError)

    if the source encoding cannot be converted to UTF-8

  • (ArgumentError)

    if the document uses an unknown encoding with @charset



55
56
57
58
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass.rb', line 55

def self.compile(contents, options = {})
  options[:syntax] ||= :scss
  Engine.new(contents, options).to_css
end

+ (String) compile_file(filename, options = {}) + compile_file(filename, css_filename, options = {})

Compile a file on disk to CSS.

Overloads:

  • + (String) compile_file(filename, options = {})

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

    Parameters:

    • filename (String)

      The path to the Sass, SCSS, or CSS file on disk.

    • options ({Symbol => Object}) (defaults to: {})

      An options hash; see the Sass options documentation

    Returns:

    • (String)

      The compiled CSS.

  • + compile_file(filename, css_filename, options = {})

    Write the compiled CSS to a file.

    Parameters:

    • filename (String)

      The path to the Sass, SCSS, or CSS file on disk.

    • options ({Symbol => Object}) (defaults to: {})

      An options hash; see the Sass options documentation

    • css_filename (String)

      The location to which to write the compiled CSS.

Raises:

  • (Sass::SyntaxError)

    if there’s an error in the document

  • (Encoding::UndefinedConversionError)

    if the source encoding cannot be converted to UTF-8

  • (ArgumentError)

    if the document uses an unknown encoding with @charset



82
83
84
85
86
87
88
89
90
91
92
93
# File '/Users/ceppstei/Projects/sass-lang/.sass/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

+ (Array<String, Pathname, Sass::Importers::Base>) load_paths

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 Engine. They are lower-precedence than any load paths passed in via the :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.

Examples:

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

Returns:



37
38
39
40
41
42
43
# File '/Users/ceppstei/Projects/sass-lang/.sass/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