Skip to content

Commit

Permalink
Rebase pull benlangfeld#21 and fix Rails 4 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid M. Said authored and grncdr committed Mar 5, 2013
1 parent 3618b82 commit f6230e5
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions lib/mobile-fu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,41 +168,27 @@ def mobile_exempt?
end
end

# the following code are obtained from https://github.com/cannikin/format_fallback
module ActionView
class PathSet < Array

def find_with_default_template(path, prefix = nil, partial = false, details = {}, key = nil)
class PathSet
def find_with_default_template(path, prefix = nil, partial = false, details = {}, keys = [], key = nil)
if prefix == "layouts"
# Layouts have their own way of managing fallback, better leave them alone
find_without_default_template(path, prefix, partial, details, key)
find_without_default_template(path, prefix, partial, details, keys, key)
else
begin
find_without_default_template(path, prefix, partial, details, key)
find_without_default_template(path, prefix, partial, details, keys, key)
rescue MissingTemplate => e
raise e if details[:formats] == [:html]
html_details = details.dup.merge(:formats => [:html])
find_without_default_template(path, prefix, partial, html_details, key)
find_without_default_template(path, prefix, partial, html_details, keys, key)
end
end
end
alias_method_chain :find, :default_template

end

class Resolver

def cached(key, prefix, name, partial)
return yield unless key && caching?
cache_content = yield
if cache_content.empty?
[]
else
@cached[key][prefix][name][partial] ||= cache_content
end
end

end
end
# end of code obtained from https://github.com/cannikin/format_fallback

if Rails::VERSION::MAJOR < 3
ActionController::Base.send :include, ActionController::MobileFu
Expand Down

0 comments on commit f6230e5

Please sign in to comment.