Module: ActionView::LookupContext::ViewPaths
- Included in:
- ActionView::LookupContext
- Defined in:
- lib/action_view/lookup_context.rb
Overview
Helpers related to template lookup using the lookup context information.
Instance Attribute Summary collapse
-
#view_paths ⇒ Object
Returns the value of attribute view_paths.
Instance Method Summary collapse
- #exists?(name, prefixes = [], partial = false, keys = [], options = {}) ⇒ Boolean (also: #template_exists?)
- #find(name, prefixes = [], partial = false, keys = [], options = {}) ⇒ Object (also: #find_template)
- #find_all(name, prefixes = [], partial = false, keys = [], options = {}) ⇒ Object
-
#with_fallbacks ⇒ Object
Add fallbacks to the view paths.
Instance Attribute Details
#view_paths ⇒ Object
Returns the value of attribute view_paths.
100 101 102 |
# File 'lib/action_view/lookup_context.rb', line 100 def view_paths @view_paths end |
Instance Method Details
#exists?(name, prefixes = [], partial = false, keys = [], options = {}) ⇒ Boolean Also known as: template_exists?
117 118 119 |
# File 'lib/action_view/lookup_context.rb', line 117 def exists?(name, prefixes = [], partial = false, keys = [], = {}) @view_paths.exists?(*args_for_lookup(name, prefixes, partial, keys, )) end |
#find(name, prefixes = [], partial = false, keys = [], options = {}) ⇒ Object Also known as: find_template
108 109 110 |
# File 'lib/action_view/lookup_context.rb', line 108 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 = [], options = {}) ⇒ Object
113 114 115 |
# File 'lib/action_view/lookup_context.rb', line 113 def find_all(name, prefixes = [], partial = false, keys = [], = {}) @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, )) end |
#with_fallbacks ⇒ Object
Add fallbacks to the view paths. Useful in cases you are rendering a :file.
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/action_view/lookup_context.rb', line 123 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 |