Permalink
Browse files

Assets no longer has knowledge of sinatra

That's all in the plugin part
  • Loading branch information...
1 parent d436e1d commit 474aeefc3e9d0836c5c8f1fe91878f3a8a03e8f7 @namelessjon committed Mar 30, 2012
Showing with 8 additions and 8 deletions.
  1. +3 −3 lib/sinatra/simple_assets.rb
  2. +5 −5 lib/sinatra/simple_assets/assets.rb
View
6 lib/sinatra/simple_assets.rb
@@ -5,20 +5,20 @@ module Sinatra
module SimpleAssets
module Helpers
def stylesheet(bundle)
- settings.assets.paths_for("#{bundle}.css").map do |file|
+ settings.assets.paths_for("#{bundle}.css", settings.environment).map do |file|
"<link rel=\"stylesheet\" href=\"#{url(file)}\">"
end.join("\n")
end
def javascript(bundle)
- settings.assets.paths_for("#{bundle}.js").map do |file|
+ settings.assets.paths_for("#{bundle}.js", settings.environment).map do |file|
"<script src=\"#{url(file)}\"></script>"
end.join("\n")
end
end
def assets(&block)
- @assets ||= Assets.new(self, &block)
+ @assets ||= Assets.new(self.public_folder, &block)
end
def self.registered(app)
View
10 lib/sinatra/simple_assets/assets.rb
@@ -2,8 +2,8 @@
module Sinatra
module SimpleAssets
class Assets
- def initialize(app, &block)
- @app = app
+ def initialize(root, &block)
+ @root = root
@bundles = {}
@hashes = {}
instance_eval(&block)
@@ -18,15 +18,15 @@ def js(bundle, files)
end
def create_bundle(name, type, files)
- bundle = Bundle.new(name, type, @app.public_folder, files)
+ bundle = Bundle.new(name, type, @root, files)
@bundles[bundle.name] = bundle
end
- def paths_for(bundle)
+ def paths_for(bundle, environment = :development)
bundle = @bundles[bundle]
return [] unless bundle
- if @app.environment == :production
+ if environment == :production
@hashes[bundle.hash_name] = bundle.name
[bundle.hashed_path]
else

0 comments on commit 474aeef

Please sign in to comment.