Created
August 13, 2011 01:29
-
-
Save brentkirby/1143362 to your computer and use it in GitHub Desktop.
sprockets circular dependency demo
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
class AssetHandler < Sprockets::Environment | |
def initialize | |
Sprockets.register_engine '.scss', Tipsy::Sass::Template | |
super(Tipsy.root) do |env| | |
env.static_root = Tipsy.options.asset_path | |
end | |
Tipsy.sprockets = self | |
configure_paths! | |
configure_compass! | |
self | |
end | |
end |
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
# Function that initializes the server. Tipsy::Static subclasses Rack::Static but allows it to continue down the | |
# app chain if theres a 404. | |
# I'm subclassing Sprockets::Environment with an internal class so I can do the setup at the same time. | |
def init! | |
Rack::Builder.new { | |
use Rack::CommonLogger | |
use Rack::ShowStatus | |
use Rack::ShowExceptions | |
use Tipsy::StaticFile, :root => Tipsy.options.public_path, :urls => %w[/] | |
run Rack::Cascade.new([ | |
Rack::URLMap.new({ "/#{File.basename(Tipsy.options.asset_path)}" => Tipsy::AssetHandler.new }), | |
Tipsy::Server.new | |
]) | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment