Skip to content

Instantly share code, notes, and snippets.

@joshprice
Created February 6, 2010 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joshprice/296705 to your computer and use it in GitHub Desktop.
Save joshprice/296705 to your computer and use it in GitHub Desktop.
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