From ae0f133800ff7629e3f554bbb8af5d9b9e5e71fa Mon Sep 17 00:00:00 2001 From: Norman Clarke Date: Tue, 22 May 2012 16:26:16 -0300 Subject: [PATCH] Remove last vestiges of Sass and simplifiy loading --- init.rb | 19 +------------------ lib/haml.rb | 32 +------------------------------- lib/haml/filters.rb | 2 +- lib/haml/railtie.rb | 10 +--------- 4 files changed, 4 insertions(+), 59 deletions(-) diff --git a/init.rb b/init.rb index f8b3dab1..712d022c 100644 --- a/init.rb +++ b/init.rb @@ -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" \ No newline at end of file diff --git a/lib/haml.rb b/lib/haml.rb index c3bdfef4..cded099b 100644 --- a/lib/haml.rb +++ b/lib/haml.rb @@ -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) diff --git a/lib/haml/filters.rb b/lib/haml/filters.rb index a1173174..c91baef3 100644 --- a/lib/haml/filters.rb +++ b/lib/haml/filters.rb @@ -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 diff --git a/lib/haml/railtie.rb b/lib/haml/railtie.rb index 4c254115..d30791fc 100644 --- a/lib/haml/railtie.rb +++ b/lib/haml/railtie.rb @@ -1,16 +1,8 @@ -if Haml::Util.ap_geq_3? && !Haml::Util.ap_geq?("3.0.0.beta4") - raise <