Remove last vestiges of Sass and simplifiy loading

This commit is contained in:
Norman Clarke 2012-05-22 16:26:16 -03:00
parent f7b653706d
commit ae0f133800
4 changed files with 4 additions and 59 deletions

19
init.rb
View File

@ -1,18 +1 @@
begin
require File.join(File.dirname(__FILE__), 'lib', 'haml') # From here
rescue LoadError
begin
require 'haml' # From gem
rescue LoadError => e
# gems:install may be run to install Haml with the skeleton plugin
# but not the gem itself installed.
# Don't die if this is the case.
raise e unless defined?(Rake) &&
(Rake.application.top_level_tasks.include?('gems') ||
Rake.application.top_level_tasks.include?('gems:install'))
end
end
# Load Haml.
# Haml may be undefined if we're running gems:install.
Haml.init_rails(binding) if defined?(Haml)
require "haml"

View File

@ -1,6 +1,3 @@
dir = File.dirname(__FILE__)
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
require 'haml/version'
# The module that contains everything Haml-related:
@ -13,35 +10,8 @@ require 'haml/version'
#
# Also see the {file:REFERENCE.md full Haml reference}.
module Haml
# 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.
#
# @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
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
end
require 'haml/util'
require 'haml/engine'
require 'haml/railtie'
require 'haml/railtie' if defined?(Rails)

View File

@ -16,7 +16,7 @@ module Haml
# Loads an external template engine from
# [Tilt](https://github.com/rtomayko/tilt) as a filter.
def register_tilt_filter(name, options = {})
if const_defined?(name.to_s, false)
if const_defined?(name.to_s)
raise "#{name} filter already defined"
end

View File

@ -1,16 +1,8 @@
if Haml::Util.ap_geq_3? && !Haml::Util.ap_geq?("3.0.0.beta4")
raise <<ERROR
Haml no longer supports Rails 3 versions before beta 4.
Please upgrade to Rails 3.0.0.beta4 or later.
ERROR
end
# Rails 3.0.0.beta.2+
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
require 'haml/template/options'
ActiveSupport.on_load(:before_initialize) do
ActiveSupport.on_load(:action_view) do
Haml.init_rails(binding)
require "haml/template"
end
end
end