diff --git a/doc-src/HAML_CHANGELOG.md b/doc-src/HAML_CHANGELOG.md index 487f9cc9..40e6d504 100644 --- a/doc-src/HAML_CHANGELOG.md +++ b/doc-src/HAML_CHANGELOG.md @@ -8,6 +8,9 @@ * The `form_tag` Rails helper is now properly marked as HTML-safe when using Rails' XSS protection with Rails 2.3.5. +* Calls to `defined?` shouldn't interfere with Rails' autoloading + in very old versions (1.2.x). + ## 2.2.19 [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.19). diff --git a/doc-src/SASS_CHANGELOG.md b/doc-src/SASS_CHANGELOG.md index 11b0d339..486282f6 100644 --- a/doc-src/SASS_CHANGELOG.md +++ b/doc-src/SASS_CHANGELOG.md @@ -11,6 +11,9 @@ rather than letting the exception bubble up. This is consistent with other sorts of sassc corruption handling. +* Calls to `defined?` shouldn't interfere with Rails' autoloading + in very old versions (1.2.x). + ## 2.2.19 [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.18). diff --git a/lib/haml/helpers/action_view_mods.rb b/lib/haml/helpers/action_view_mods.rb index a05373ff..1ff50094 100644 --- a/lib/haml/helpers/action_view_mods.rb +++ b/lib/haml/helpers/action_view_mods.rb @@ -125,7 +125,7 @@ module ActionView @template_object.send :is_haml? end - unless defined?(ActionView::Helpers::ActiveRecordInstanceTag) + unless defined?(ActionView::Helpers) && defined?(ActionView::Helpers::ActiveRecordInstanceTag) alias_method :content_tag_without_haml, :content_tag alias_method :content_tag, :content_tag_with_haml end diff --git a/lib/haml/template.rb b/lib/haml/template.rb index b738c320..8af68720 100644 --- a/lib/haml/template.rb +++ b/lib/haml/template.rb @@ -46,7 +46,8 @@ end # Decide how we want to load Haml into Rails. # Patching was necessary for versions <= 2.0.1, # but we can make it a normal handler for higher versions. -if defined?(ActionView::TemplateHandler) || defined?(ActionView::Template::Handler) +if defined?(ActionView::TemplateHandler) || + (defined?(ActionView::Template) && defined?(ActionView::Template::Handler)) require 'haml/template/plugin' else require 'haml/template/patch' diff --git a/lib/haml/template/plugin.rb b/lib/haml/template/plugin.rb index a270a38c..0a8ce842 100644 --- a/lib/haml/template/plugin.rb +++ b/lib/haml/template/plugin.rb @@ -3,8 +3,11 @@ module Haml class Plugin < Haml::Util.av_template_class(:Handler) - if defined?(ActionView::TemplateHandlers::Compilable) || - defined?(ActionView::Template::Handlers::Compilable) + if (defined?(ActionView::TemplateHandlers) && + defined?(ActionView::TemplateHandlers::Compilable)) || + (defined?(ActionView::Template) && + defined?(ActionView::Template::Handlers) && + defined?(ActionView::Template::Handlers::Compilable)) include Haml::Util.av_template_class(:Handlers)::Compilable end diff --git a/lib/sass/plugin/rack.rb b/lib/sass/plugin/rack.rb index 9275b4ba..b61721e3 100644 --- a/lib/sass/plugin/rack.rb +++ b/lib/sass/plugin/rack.rb @@ -48,12 +48,12 @@ module Sass # This is automatically done once the Rack plugin is activated. # This is done so that the stylesheets aren't checked twice for each request. def self.disable_native_plugin! - if defined?(Merb::Rack::Application) && + if defined?(Merb::Rack) && defined?(Merb::Rack::Application) && Haml::Util.has?(:instance_method, Merb::Rack::Application, :call_without_sass) Merb::Rack::Application.instance_eval {alias_method :call, :call_without_sass} end - if defined?(ActionDispatch::Callbacks.to_prepare) + if defined?(ActionDispatch::Callbacks) && defined?(ActionDispatch::Callbacks.to_prepare) ActionDispatch::Callbacks.skip_callback(:prepare, :__sass_process) elsif defined?(ActionController::Base) && Haml::Util.has?(:instance_method, ActionController::Base, :sass_old_process) diff --git a/lib/sass/plugin/rails.rb b/lib/sass/plugin/rails.rb index 0d2c6292..07412677 100644 --- a/lib/sass/plugin/rails.rb +++ b/lib/sass/plugin/rails.rb @@ -7,7 +7,8 @@ unless defined?(Sass::RAILS_LOADED) :always_check => Haml::Util.rails_env != "production", :full_exception => Haml::Util.rails_env != "production") - if defined?(ActionDispatch::Callbacks.to_prepare) + if defined?(ActionDispatch::Callbacks) && + defined?(ActionDispatch::Callbacks.to_prepare) # Rails >= 3.0.0 ActionDispatch::Callbacks.to_prepare(:sass_process) {Sass::Plugin.check_for_updates} else