Module: Sass

Extended by:
Haml::Version
Defined in:
lib/sass.rb,
lib/sass/css.rb,
lib/sass/repl.rb,
lib/sass/scss.rb,
lib/sass/error.rb,
lib/sass/engine.rb,
lib/sass/plugin.rb,
lib/sass/script.rb,
lib/sass/scss/rx.rb,
lib/sass/selector.rb,
lib/sass/callbacks.rb,
lib/sass/importers.rb,
lib/sass/tree/node.rb,
lib/sass/cache_store.rb,
lib/sass/environment.rb,
lib/sass/plugin/rack.rb,
lib/sass/scss/parser.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/script/css_lexer.rb,
lib/sass/scss/sass_parser.rb,
lib/sass/tree/import_node.rb,
lib/sass/script/css_parser.rb,
lib/sass/scss/script_lexer.rb,
lib/sass/selector/sequence.rb,
lib/sass/scss/script_parser.rb,
lib/sass/scss/static_parser.rb,
lib/sass/tree/variable_node.rb,
lib/sass/tree/mixin_def_node.rb,
lib/sass/importers/filesystem.rb,
lib/sass/plugin/configuration.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: Callbacks, Importers, Plugin, SCSS, Script, Selector, Tree Classes: CSS, CacheStore, Engine, Environment, FileCacheStore, InMemoryCacheStore, Mixin, Repl, SyntaxError, UnitConversionError

Constant Summary collapse

VERSION =

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

version[:string]
MERB_LOADED =
true
RAILS_LOADED =
true
GENERIC_LOADED =
true

Constants included from Haml::Util

Haml::Util::CHARSET_REGEXPS, Haml::Util::ENCODINGS_TO_CHECK, Haml::Util::RUBY_VERSION

Class Method Summary collapse

Methods included from Haml::Version

version

Methods included from Haml::Util

#abstract, #ap_geq?, #ap_geq_3?, #assert_html_safe!, #av_template_class, #caller_info, #check_encoding, #check_haml_encoding, #check_sass_encoding, #def_static_method, #dump, #enum_cons, #enum_slice, #enum_with_index, #flatten, #haml_warn, #has?, #html_safe, #intersperse, #lcs, #load, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #ord, #paths, #powerset, #rails_env, #rails_root, #rails_safe_buffer_class, #rails_xss_safe?, #restrict, #ruby1_8?, #ruby1_8_6?, #scope, #set_eql?, #set_hash, #silence_haml_warnings, #silence_warnings, #static_method_name, #strip_string_array, #substitute, #to_hash, #version_geq, #version_gt, #windows?

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



32
33
34
35
# File 'lib/sass.rb', line 32

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

    Returns The compiled CSS.

    Returns:

    • (String)

      The compiled CSS.

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

    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



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/sass.rb', line 52

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