-
-
Save timriley/297744 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
helpers do | |
def mobile_request? | |
[ /AppleWebKit.*Mobile/, /Android.*AppleWebKit/ ].any? {|r| request.env['HTTP_USER_AGENT'] =~ r} | |
end | |
def mobile_file(name) | |
File.exist?("#{options.views}/#{name}#{@mobile}.haml") ? :"#{name}#{@mobile}" : name.to_sym | |
end | |
def partial(name) | |
haml mobile_file("_#{name}"), :layout => false | |
end | |
def deliver(name) | |
haml mobile_file(name), :layout => :"layout#{@mobile}" | |
end | |
end | |
before do | |
@mobile = mobile_request? ? ".mobile" : "" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment