Created
September 28, 2011 06:59
-
-
Save datenimperator/1247187 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compass configuration from inside a rails3 engine | |
require 'compass' | |
require 'compass/app_integration/rails' | |
configuration = StringIO.new(<<-CONFIG) | |
project_type = :rails | |
css_dir = "public/stylesheets" | |
sass_dir = "app/stylesheets" | |
CONFIG | |
Compass.reset_configuration! | |
Compass.add_configuration(configuration, __FILE__) | |
Compass.configuration.project_path = Rails.root.to_s | |
Compass.discover_extensions! | |
Compass.configure_sass_plugin! | |
if Rails.env.development? | |
Compass.configuration.on_stylesheet_saved {|filepath| Rails.logger.debug("Compass saved #{filepath}") } | |
Compass.configuration.on_stylesheet_error {|filepath, message| Rails.logger.error("Compass has error in #{filepath}: #{message}") } | |
end | |
Compass.handle_configuration_change! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Separately, this is how the engine adds its sass templates to the | |
# `surrounding` Rails.application | |
class Engine < Rails::Engine | |
initializer "Add to Sass load path", :after=>"compass.initialize_rails" do | |
# root is initialized elsewhere and contains a PathName pointing to the engine's root directory | |
Sass::Plugin.add_template_location(root.join('app', 'stylesheets'), Rails.root.join('public', 'stylesheets', 'engine')) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment