module ActionView::LookupContext::ViewPaths
def args_for_lookup(name, prefixes, partial, keys, details_options) #:nodoc:
def args_for_lookup(name, prefixes, partial, keys, details_options) #:nodoc: name, prefixes = normalize_name(name, prefixes) details, details_key = detail_args_for(details_options) [name, prefixes, partial || false, details, details_key, keys] end
def detail_args_for(options)
def detail_args_for(options) return @details, details_key if options.empty? # most common path. user_details = @details.merge(options) if @cache details_key = DetailsKey.get(user_details) else details_key = nil end [user_details, details_key] end
def exists?(name, prefixes = [], partial = false, keys = [], options = {})
def exists?(name, prefixes = [], partial = false, keys = [], options = {}) @view_paths.exists?(*args_for_lookup(name, prefixes, partial, keys, options)) end
def find(name, prefixes = [], partial = false, keys = [], options = {})
def find(name, prefixes = [], partial = false, keys = [], options = {}) @view_paths.find(*args_for_lookup(name, prefixes, partial, keys, options)) end
def find_all(name, prefixes = [], partial = false, keys = [], options = {})
def find_all(name, prefixes = [], partial = false, keys = [], options = {}) @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, options)) end
def normalize_name(name, prefixes) #:nodoc:
name instead of the prefix.
as well as incorrectly putting part of the path in the template
Support legacy foo.erb names even though we now ignore .erb
def normalize_name(name, prefixes) #:nodoc: prefixes = prefixes.presence parts = name.to_s.split('/') parts.shift if parts.first.empty? name = parts.pop return name, prefixes || [""] if parts.empty? parts = parts.join('/') prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts] return name, prefixes end
def view_paths=(paths)
Whenever setting view paths, makes a copy so we can manipulate then in
def view_paths=(paths) @view_paths = ActionView::PathSet.new(Array(paths)) end
def with_fallbacks
def with_fallbacks added_resolvers = 0 self.class.fallbacks.each do |resolver| next if view_paths.include?(resolver) view_paths.push(resolver) added_resolvers += 1 end yield ensure added_resolvers.times { view_paths.pop } end