Merb support

This commit is contained in:
Chris Eppstein 2008-08-24 12:57:49 -07:00
parent 6a64c44feb
commit 6efe31a066
4 changed files with 49 additions and 0 deletions

View File

@ -68,6 +68,7 @@ lib/compass/exec.rb
lib/compass/frameworks/blueprint.rb
lib/compass/frameworks/compass.rb
lib/compass/frameworks.rb
lib/compass/merb.rb
lib/compass/validate/COPYRIGHT.html
lib/compass/validate/css-validator-javadoc.jar
lib/compass/validate/css-validator.jar

View File

@ -54,6 +54,7 @@ extra_rdoc_files:
- lib/compass/frameworks/blueprint.rb
- lib/compass/frameworks/compass.rb
- lib/compass/frameworks.rb
- lib/compass/merb.rb
- lib/compass/validate/COPYRIGHT.html
- lib/compass/validate/css-validator-javadoc.jar
- lib/compass/validate/css-validator.jar
@ -138,6 +139,7 @@ files:
- lib/compass/frameworks/blueprint.rb
- lib/compass/frameworks/compass.rb
- lib/compass/frameworks.rb
- lib/compass/merb.rb
- lib/compass/validate/COPYRIGHT.html
- lib/compass/validate/css-validator-javadoc.jar
- lib/compass/validate/css-validator.jar

View File

@ -11,3 +11,6 @@ module Compass
end
require File.join(File.dirname(__FILE__), 'compass', 'frameworks')
# make sure we're running inside Merb
require File.join(File.dirname(__FILE__), 'compass', 'merb') if defined?(Merb::Plugins)

43
lib/compass/merb.rb Normal file
View File

@ -0,0 +1,43 @@
# To configure Merb to use compass do the following:
# Merb::BootLoader.after_app_loads do
# require 'merb-haml'
# require 'compass'
# end
#
# To use a different sass stylesheets locations as is recommended by compass
# add this configuration to your configuration block:
#
# Merb::Config.use do |c|
# c[:compass] = {
# :stylesheets => 'app/stylesheets',
# :compiled_stylesheets => 'public/stylesheets/compiled'
# }
# 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"
Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
end
# default the compass configuration if they didn't set it up yet.
Merb::Config[:compass] ||= {}
# default sass stylesheet location unless configured to something else
Merb::Config[:compass][:stylesheets] ||= Merb.dir_for(:stylesheet) / "sass"
# default sass css location unless configured to something else
Merb::Config[:compass][:compiled_stylesheets] ||= Merb.dir_for(:stylesheet)
#define the template hash for the project stylesheets as well as the framework stylesheets.
template_location = {
Merb::Config[:compass][:stylesheets] => Merb::Config[:compass][:compiled_stylesheets]
}
Compass::Frameworks::ALL.each do |framework|
template_location[framework.stylesheets_directory] = File.join(Merb::Config[:compass][:compiled_stylesheets], framework.name)
end
#configure Sass to know about all these sass locations.
Sass::Plugin.options[:template_location] = template_location
end