mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Remove last vestiges of Sass and simplifiy loading
This commit is contained in:
parent
f7b653706d
commit
ae0f133800
4 changed files with 4 additions and 59 deletions
19
init.rb
19
init.rb
|
@ -1,18 +1 @@
|
||||||
begin
|
require "haml"
|
||||||
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)
|
|
32
lib/haml.rb
32
lib/haml.rb
|
@ -1,6 +1,3 @@
|
||||||
dir = File.dirname(__FILE__)
|
|
||||||
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
|
||||||
|
|
||||||
require 'haml/version'
|
require 'haml/version'
|
||||||
|
|
||||||
# The module that contains everything Haml-related:
|
# The module that contains everything Haml-related:
|
||||||
|
@ -13,35 +10,8 @@ require 'haml/version'
|
||||||
#
|
#
|
||||||
# Also see the {file:REFERENCE.md full Haml reference}.
|
# Also see the {file:REFERENCE.md full Haml reference}.
|
||||||
module Haml
|
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
|
end
|
||||||
|
|
||||||
require 'haml/util'
|
require 'haml/util'
|
||||||
require 'haml/engine'
|
require 'haml/engine'
|
||||||
require 'haml/railtie'
|
require 'haml/railtie' if defined?(Rails)
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Haml
|
||||||
# Loads an external template engine from
|
# Loads an external template engine from
|
||||||
# [Tilt](https://github.com/rtomayko/tilt) as a filter.
|
# [Tilt](https://github.com/rtomayko/tilt) as a filter.
|
||||||
def register_tilt_filter(name, options = {})
|
def register_tilt_filter(name, options = {})
|
||||||
if const_defined?(name.to_s, false)
|
if const_defined?(name.to_s)
|
||||||
raise "#{name} filter already defined"
|
raise "#{name} filter already defined"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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)
|
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
||||||
require 'haml/template/options'
|
require 'haml/template/options'
|
||||||
ActiveSupport.on_load(:before_initialize) do
|
ActiveSupport.on_load(:before_initialize) do
|
||||||
ActiveSupport.on_load(:action_view) do
|
ActiveSupport.on_load(:action_view) do
|
||||||
Haml.init_rails(binding)
|
require "haml/template"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue