Module: Haml

Extended by:
Version
Defined in:
lib/haml.rb,
lib/haml/exec.rb,
lib/haml/html.rb,
lib/haml/root.rb,
lib/haml/util.rb,
lib/haml/error.rb,
lib/haml/buffer.rb,
lib/haml/engine.rb,
lib/haml/parser.rb,
lib/haml/shared.rb,
lib/haml/filters.rb,
lib/haml/filters.rb,
lib/haml/helpers.rb,
lib/haml/version.rb,
lib/haml/compiler.rb,
lib/haml/html/erb.rb,
lib/haml/template.rb,
lib/haml/template/plugin.rb,
lib/haml/helpers/xss_mods.rb,
lib/haml/template/options.rb,
lib/haml/helpers/action_view_extensions.rb

Overview

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

Defined Under Namespace

Modules: Compiler, Exec, Filters, Helpers, Parser, Shared, Template, Util, Version Classes: Buffer, Engine, Error, HTML, Plugin, SyntaxError

Constant Summary collapse

ROOT_DIR =

The root directory of the Haml 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 Haml. A more fine-grained representation is available from Haml.version.

Constants included from Util

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

Class Method Summary collapse

Methods included from Version

version

Methods included from Util

#abstract, #ap_geq?, #ap_geq_3?, #assert_html_safe!, #av_template_class, #caller_info, #check_encoding, #check_haml_encoding, #def_static_method, #dump, #enum_cons, #enum_slice, #enum_with_index, #flatten, #haml_warn, #has?, #html_safe, #inspect_obj, #intersperse, #ironruby?, #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, #try_sass, #version_geq, #version_gt, #windows?

Class Method Details

.init_rails(binding)

Initializes Haml for Rails.

This method is called by init.rb, which is run by Rails on startup. We use it rather than putting stuff straight into init.rb so we can change the initialization behavior without modifying the file itself.

Parameters:

  • binding (Binding)

    The context of the init.rb file. This isn't actually used; it's just passed in in case it needs to be used in the future



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/haml.rb', line 27

def self.init_rails(binding)
  # 2.2 <= Rails < 3
  if defined?(Rails) && Rails.respond_to?(:configuration) &&
      Rails.configuration.respond_to?(:after_initialize) &&
      !Haml::Util.ap_geq_3?
    Rails.configuration.after_initialize do
      next if defined?(Sass)
      autoload(:Sass, 'sass/rails2_shim')
      # resolve autoload if it looks like they're using Sass without options
      Sass if File.exist?(File.join(RAILS_ROOT, 'public/stylesheets/sass'))
    end
  end

  # No &method here for Rails 2.1 compatibility
  %w[haml/template].each {|f| require f}
end