Permalink
Browse files

Store bundles

  • Loading branch information...
1 parent d0efd66 commit e50a13d66dcd92bb3dd6b3b2f22ad2e06767a23a @peteog committed Dec 15, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 lib/sinatra/simple_assets.rb
@@ -18,23 +18,47 @@ def javascript(name)
end
end
+ class Bundle
+ def initialize(name, type, root, files)
+ @name = name
+ @type = type
+ @root = root
+ @files = files
+ end
+
+ def name
+ "#{@name}.#{@type}"
+ end
+ end
+
class Assets
def initialize(app, &block)
@app = app
+ @bundles = {}
+ @hashes = {}
instance_eval(&block)
end
def css(bundle, files)
+ create_bundle(bundle, :css, files)
end
def js(bundle, files)
+ create_bundle(bundle, :js, files)
+ end
+
+ def create_bundle(name, type, name, files)
+ bundle = Bundle.new(name, type, @app.public_folder, files)
+ @bundles[bundle.name] = bundle
end
def paths_for(bundle)
[]
end
def content_for(bundle)
+ bundle = @bundles[@hashes[bundle]]
+ bundle.content if bundle
end
end

0 comments on commit e50a13d

Please sign in to comment.