Module: Sinatra::SimpleAssets
- Defined in:
- lib/sinatra/simple_assets.rb
Defined Under Namespace
Modules: Helpers Classes: Assets, Bundle
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/sinatra/simple_assets.rb', line 132 def self.registered(app) app.helpers SimpleAssets::Helpers [ { :route => '/stylesheets', :type => :css }, { :route => '/javascripts', :type => :js } ].each do |r| app.get "#{r[:route]}/:bundle" do bundle = params[:bundle] assets = settings.assets exists = assets.bundle_exists?(bundle) etag bundle if exists not_found unless exists cache_control :public, :must_revalidate, :max_age => 86400 content_type r[:type] assets.content_for(bundle) end end end |