Module: Sass

Extended by:
Version
Defined in:
lib/sass.rb,
lib/sass/css.rb,
lib/sass/exec.rb,
lib/sass/repl.rb,
lib/sass/root.rb,
lib/sass/scss.rb,
lib/sass/util.rb,
lib/sass/error.rb,
lib/sass/engine.rb,
lib/sass/logger.rb,
lib/sass/plugin.rb,
lib/sass/script.rb,
lib/sass/shared.rb,
lib/sass/scss/rx.rb,
lib/sass/version.rb,
lib/sass/selector.rb,
lib/sass/callbacks.rb,
lib/sass/importers.rb,
lib/sass/tree/node.rb,
lib/sass/environment.rb,
lib/sass/plugin/rack.rb,
lib/sass/scss/parser.rb,
lib/sass/cache_stores.rb,
lib/sass/script/lexer.rb,
lib/sass/script/parser.rb,
lib/sass/importers/base.rb,
lib/sass/script/funcall.rb,
lib/sass/tree/root_node.rb,
lib/sass/tree/warn_node.rb,
lib/sass/script/variable.rb,
lib/sass/scss/css_parser.rb,
lib/sass/selector/simple.rb,
lib/sass/tree/debug_node.rb,
lib/sass/util/subset_map.rb,
lib/sass/logger/log_level.rb,
lib/sass/script/css_lexer.rb,
lib/sass/scss/sass_parser.rb,
lib/sass/tree/import_node.rb,
lib/sass/tree/return_node.rb,
lib/sass/cache_stores/base.rb,
lib/sass/cache_stores/null.rb,
lib/sass/script/css_parser.rb,
lib/sass/scss/script_lexer.rb,
lib/sass/selector/sequence.rb,
lib/sass/cache_stores/chain.rb,
lib/sass/scss/script_parser.rb,
lib/sass/scss/static_parser.rb,
lib/sass/tree/function_node.rb,
lib/sass/tree/variable_node.rb,
lib/sass/cache_stores/memory.rb,
lib/sass/tree/mixin_def_node.rb,
lib/sass/importers/filesystem.rb,
lib/sass/plugin/configuration.rb,
lib/sass/cache_stores/filesystem.rb,
lib/sass/selector/comma_sequence.rb,
lib/sass/plugin/staleness_checker.rb,
lib/sass/selector/simple_sequence.rb,
lib/sass/selector/abstract_sequence.rb

Overview

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.

Defined Under Namespace

Modules: CacheStores, Callbacks, Exec, Importers, Logger, Plugin, SCSS, Script, Selector, Shared, Tree, Util, Version Classes: CSS, Callable, Engine, Environment, Repl, SyntaxError, UnitConversionError

Constant Summary collapse

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__, "../../.."))
VERSION =

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

MERB_LOADED =
true
RAILS_LOADED =
true
GENERIC_LOADED =
true

Constants included from Util

Util::CHARSET_REGEXPS, Util::ENCODINGS_TO_CHECK, Util::RUBY_ENGINE, Util::RUBY_VERSION

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Version

version

Methods included from Util

#abstract, #ap_geq?, #ap_geq_3?, #av_template_class, #caller_info, #check_encoding, #check_sass_encoding, #enum_cons, #enum_slice, #enum_with_index, #extract_values, #flatten, #has?, #inject_values, #inspect_obj, #intersperse, #ironruby?, #lcs, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #ord, #paths, #powerset, #rails_env, #rails_root, #restrict, #ruby1_8?, #ruby1_8_6?, #sass_warn, #scope, #set_eql?, #set_hash, #silence_sass_warnings, #silence_warnings, #strip_string_array, #substitute, #to_hash, #version_geq, #version_gt, #windows?, #with_extracted_values

Class Attribute Details

.logger

Returns the value of attribute logger.



11
12
13
# File 'lib/sass/logger.rb', line 11

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



30
31
32
33
# File 'lib/sass.rb', line 30

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

.compile_file(filename, options = {}) ⇒ String .compile_file(filename, css_filename, options = {})

Compile a file on disk to CSS.

Overloads:

  • .compile_file(filename, options = {}) ⇒ String

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

    Returns:

    • (String)

      The compiled CSS.

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

    Write the compiled CSS to a file.

    Parameters:

    • css_filename (String)

      The location to which to write the compiled CSS.

Parameters:

  • filename (String)

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

  • options ({Symbol => Object})

    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



54
55
56
57
58
59
60
61
62
63
64
65
# 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