Module: ActionView::LookupContext::ViewPaths

Included in:
ActionView::LookupContext
Defined in:
actionpack/lib/action_view/lookup_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#view_pathsObject

Returns the value of attribute view_paths



76
77
78
# File 'actionpack/lib/action_view/lookup_context.rb', line 76

def view_paths
  @view_paths
end

Instance Method Details

#exists?(name, prefixes = [], partial = false, keys = []) ⇒ Boolean Also known as: template_exists?

Returns:

  • (Boolean)


93
94
95
# File 'actionpack/lib/action_view/lookup_context.rb', line 93

def exists?(name, prefixes = [], partial = false, keys = [])
  @view_paths.exists?(*args_for_lookup(name, prefixes, partial, keys))
end

#find(name, prefixes = [], partial = false, keys = []) ⇒ Object Also known as: find_template



84
85
86
# File 'actionpack/lib/action_view/lookup_context.rb', line 84

def find(name, prefixes = [], partial = false, keys = [])
  @view_paths.find(*args_for_lookup(name, prefixes, partial, keys))
end

#find_all(name, prefixes = [], partial = false, keys = []) ⇒ Object



89
90
91
# File 'actionpack/lib/action_view/lookup_context.rb', line 89

def find_all(name, prefixes = [], partial = false, keys = [])
  @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys))
end

#with_fallbacksObject

Add fallbacks to the view paths. Useful in cases you are rendering a :file.



99
100
101
102
103
104
105
106
107
108
109
# File 'actionpack/lib/action_view/lookup_context.rb', line 99

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