2006-12-04 00:06:39 +00:00
|
|
|
dir = File.dirname(__FILE__)
|
2008-10-12 22:38:49 -07:00
|
|
|
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
2006-12-19 02:56:49 +00:00
|
|
|
|
2009-01-25 11:02:33 -08:00
|
|
|
require 'haml/version'
|
|
|
|
|
2009-06-18 13:40:57 -07:00
|
|
|
# The module that contains everything Haml-related:
|
2008-04-07 23:09:17 -07:00
|
|
|
#
|
2009-06-18 13:40:57 -07:00
|
|
|
# * {Haml::Engine} is the class used to render Haml within Ruby code.
|
|
|
|
# * {Haml::Helpers} contains Ruby helpers available within Haml templates.
|
|
|
|
# * {Haml::Template} interfaces with web frameworks (Rails in particular).
|
|
|
|
# * {Haml::Error} is raised when Haml encounters an error.
|
|
|
|
# * {Haml::HTML} handles conversion of HTML to Haml.
|
2008-04-24 12:35:42 -07:00
|
|
|
#
|
2012-04-29 12:27:01 -03:00
|
|
|
# Also see the {file:REFERENCE.md full Haml reference}.
|
2007-12-11 10:03:44 +00:00
|
|
|
module Haml
|
2009-04-29 01:02:44 -07:00
|
|
|
# Initializes Haml for Rails.
|
|
|
|
#
|
|
|
|
# This method is called by `init.rb`,
|
2007-12-11 10:03:44 +00:00
|
|
|
# which is run by Rails on startup.
|
2009-04-29 01:02:44 -07:00
|
|
|
# We use it rather than putting stuff straight into `init.rb`
|
2007-12-11 10:03:44 +00:00
|
|
|
# so we can change the initialization behavior
|
|
|
|
# without modifying the file itself.
|
2009-04-29 01:02:44 -07:00
|
|
|
#
|
|
|
|
# @param 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
|
2007-12-11 10:03:44 +00:00
|
|
|
def self.init_rails(binding)
|
2010-10-11 20:29:07 -07:00
|
|
|
# 2.2 <= Rails < 3
|
2010-09-06 23:47:25 -07:00
|
|
|
if defined?(Rails) && Rails.respond_to?(:configuration) &&
|
2010-10-11 20:29:07 -07:00
|
|
|
Rails.configuration.respond_to?(:after_initialize) &&
|
|
|
|
!Haml::Util.ap_geq_3?
|
2010-09-06 23:47:25 -07:00
|
|
|
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
|
|
|
|
|
2008-07-30 09:58:56 -04:00
|
|
|
# No &method here for Rails 2.1 compatibility
|
2010-08-22 16:04:02 -07:00
|
|
|
%w[haml/template].each {|f| require f}
|
2007-12-11 10:03:44 +00:00
|
|
|
end
|
|
|
|
end
|
2006-12-19 02:56:49 +00:00
|
|
|
|
2008-11-22 19:17:06 -08:00
|
|
|
require 'haml/util'
|
2010-08-22 16:04:02 -07:00
|
|
|
require 'haml/engine'
|
|
|
|
require 'haml/railtie'
|