Module: Sinatra::IPhoneViews
- Defined in:
- lib/sinatra/iphone_views.rb
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/sinatra/iphone_views.rb', line 3 def self.registered(app) app.enable :reload_templates app.set :original_views, Sinatra::Application.views app.set :iphone_views, File.join(Sinatra::Application.views, 'iphone') app.before do # http://lachstock.com.au/code/mobile-pages-in-sinatra/ iphone = [/AppleWebKit.*Mobile/, /Android.*AppleWebKit/].any? { |r| request.env['HTTP_USER_AGENT'] =~ r } .views = iphone ? Sinatra::Application.iphone_views : Sinatra::Application.original_views end end |