Module: Sass

Extended by:
Features, Version
Defined in:
/usr/local/google-old/home/code/sass-site/.sass/lib/sass.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/cache_stores.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/cache_stores/base.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/cache_stores/chain.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/cache_stores/filesystem.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/cache_stores/memory.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/cache_stores/null.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/callbacks.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/css.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/engine.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/environment.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/error.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/exec.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/features.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/importers.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/importers/base.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/importers/deprecated_path.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/importers/filesystem.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/logger.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/logger/log_level.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/plugin.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/plugin/configuration.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/plugin/rack.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/plugin/staleness_checker.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/repl.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/root.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/script.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/script/css_lexer.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/script/css_parser.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/script/lexer.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/script/parser.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss/css_parser.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss/parser.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss/rx.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss/script_lexer.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss/script_parser.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/scss/static_parser.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/selector.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/selector/abstract_sequence.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/selector/comma_sequence.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/selector/sequence.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/selector/simple.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/selector/simple_sequence.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/shared.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/stack.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/at_root_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/content_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/debug_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/function_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/import_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/mixin_def_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/return_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/root_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/variable_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/tree/warn_node.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/util.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/util/cross_platform_random.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/util/normalized_map.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/util/subset_map.rb,
/usr/local/google-old/home/code/sass-site/.sass/lib/sass/util/test.rb,
/usr/local/google-old/home/code/sass-site/.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, 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 '/usr/local/google-old/home/code/sass-site/.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



60
61
62
63
# File '/usr/local/google-old/home/code/sass-site/.sass/lib/sass.rb', line 60

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



87
88
89
90
91
92
93
94
95
96
97
98
# File '/usr/local/google-old/home/code/sass-site/.sass/lib/sass.rb', line 87

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:



42
43
44
45
46
47
48
# File '/usr/local/google-old/home/code/sass-site/.sass/lib/sass.rb', line 42

def self.load_paths
  @load_paths ||= if ENV['SASS_PATH']
                    ENV['SASS_PATH'].split(Sass::Util.windows? ? ';' : ':')
                  else
                    []
                  end
end