Fixing Merb Integration (use Merb::Plugins.config instead of Merb::Config)

This commit is contained in:
Jacques Crocker 2009-07-07 22:47:27 -07:00 committed by Chris Eppstein
parent 3681187e6c
commit 4ffa08cc42
2 changed files with 46 additions and 29 deletions

View File

@ -89,6 +89,8 @@ end
task :release => :commit_revision task :release => :commit_revision
task :gem => :build
desc "Compile Examples into HTML and CSS" desc "Compile Examples into HTML and CSS"
task :examples do task :examples do
linked_haml = "tests/haml" linked_haml = "tests/haml"

View File

@ -1,43 +1,58 @@
# To configure Merb to use compass do the following: # To configure Merb to use compass do the following:
# Merb::BootLoader.after_app_loads do #
# require 'merb-haml' # Add dependencies to config/dependencies.rb
# require 'compass' #
# end # dependency "haml", ">=2.2.0"
# dependency "merb-haml", merb_gems_version
# dependency "chriseppstein-compass", :require_as => 'compass'
#
# #
# To use a different sass stylesheets locations as is recommended by compass # To use a different sass stylesheets locations as is recommended by compass
# add this configuration to your configuration block: # add this configuration to your configuration block:
# #
# Merb::Config.use do |c| # Merb::BootLoader.before_app_loads do
# c[:compass] = { # Merb::Plugins.config[:compass] = {
# :stylesheets => 'app/stylesheets', # :stylesheets => "app/stylesheets",
# :compiled_stylesheets => 'public/stylesheets/compiled' # :compiled_stylesheets => "public/stylesheets/compiled"
# } # }
# end # end
#
Merb::BootLoader.after_app_loads do module Compass
#set up sass if haml load didn't do it -- this happens when using a non-default stylesheet location. def self.setup_template_location
unless defined?(Sass::Plugin)
require "sass/plugin"
Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
end
# default the compass configuration if they didn't set it up yet. # default the compass configuration if they didn't set it up yet.
Merb::Config[:compass] ||= {} Merb::Plugins.config[:compass] ||= {}
# default sass stylesheet location unless configured to something else # default sass stylesheet location unless configured to something else
Merb::Config[:compass][:stylesheets] ||= Merb.dir_for(:stylesheet) / "sass" Merb::Plugins.config[:compass][:stylesheets] ||= Merb.dir_for(:stylesheet) / "sass"
# default sass css location unless configured to something else # default sass css location unless configured to something else
Merb::Config[:compass][:compiled_stylesheets] ||= Merb.dir_for(:stylesheet) Merb::Plugins.config[:compass][:compiled_stylesheets] ||= Merb.dir_for(:stylesheet)
#define the template hash for the project stylesheets as well as the framework stylesheets. #define the template hash for the project stylesheets as well as the framework stylesheets.
template_location = { template_location = {
Merb::Config[:compass][:stylesheets] => Merb::Config[:compass][:compiled_stylesheets] Merb::Plugins.config[:compass][:stylesheets] => Merb::Plugins.config[:compass][:compiled_stylesheets]
} }
Compass::Frameworks::ALL.each do |framework| Compass::Frameworks::ALL.each do |framework|
template_location[framework.stylesheets_directory] = Merb::Config[:compass][:compiled_stylesheets] template_location[framework.stylesheets_directory] = Merb::Plugins.config[:compass][:compiled_stylesheets]
end end
#configure Sass to know about all these sass locations. #configure Sass to know about all these sass locations.
Sass::Plugin.options[:template_location] = template_location Sass::Plugin.options[:template_location] = template_location
end end
end
Merb::BootLoader.after_app_loads do
#set up sass if haml load didn't do it -- this happens when using a non-default stylesheet location.
unless defined?(Sass::Plugin)
require "sass/plugin"
if Merb::Plugins.config[:sass]
Sass::Plugin.options = Merb::Plugins.config[:sass]
# support old (deprecatd Merb::Config[:sass] option)
elsif Merb::Config[:sass]
Sass::Plugin.options = Merb::Config[:sass]
end
end
Compass.setup_template_location
end