mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Properly print warnings for Rails 2.2+.
This commit is contained in:
parent
20a0d27e60
commit
e59b032210
5 changed files with 22 additions and 2 deletions
11
lib/haml.rb
11
lib/haml.rb
|
@ -25,6 +25,17 @@ module Haml
|
|||
# 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)
|
||||
# Rails 2.2+
|
||||
if defined?(Rails) && Rails.respond_to?(:configuration) &&
|
||||
Rails.configuration.respond_to?(:after_initialize)
|
||||
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
|
||||
|
|
|
@ -8,7 +8,7 @@ end
|
|||
# Rails 3.0.0.beta.2+
|
||||
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
||||
require 'haml/template/options'
|
||||
autoload(:Sass, 'sass/rails_shim')
|
||||
autoload(:Sass, 'sass/rails3_shim')
|
||||
ActiveSupport.on_load(:before_initialize) do
|
||||
# resolve autoload if it looks like they're using Sass without options
|
||||
Sass if File.exist?(File.join(Rails.root, 'public/stylesheets/sass'))
|
||||
|
|
9
lib/sass/rails2_shim.rb
Normal file
9
lib/sass/rails2_shim.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Haml::Util.try_sass
|
||||
Haml::Util.haml_warn(<<WARNING)
|
||||
Haml will no longer automatically load Sass in Haml 3.2.0.
|
||||
Please add config.gem 'sass' to your environment.rb.
|
||||
WARNING
|
||||
|
||||
require 'sass'
|
||||
require 'sass/plugin'
|
||||
|
2
vendor/sass
vendored
2
vendor/sass
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 66f2c9f3db8d8fe13bdd2e7f96edd938592b7c2c
|
||||
Subproject commit 4b7992f12c7275725df79748f744e5154f30b024
|
Loading…
Add table
Reference in a new issue