Module: ActionView::LookupContext::ViewPaths
- Included in:
- ActionView::LookupContext
- Defined in:
- lib/action_view/lookup_context.rb
Instance Attribute Summary collapse
-
#view_paths ⇒ Object
Returns the value of attribute view_paths.
Instance Method Summary collapse
- #exists?(name, prefix = nil, partial = false) ⇒ Boolean (also: #template_exists?)
- #find(name, prefix = nil, partial = false) ⇒ Object (also: #find_template)
- #find_all(name, prefix = nil, partial = false) ⇒ Object
-
#with_fallbacks ⇒ Object
Add fallbacks to the view paths.
Instance Attribute Details
#view_paths ⇒ Object
Returns the value of attribute view_paths.
72 73 74 |
# File 'lib/action_view/lookup_context.rb', line 72 def view_paths @view_paths end |
Instance Method Details
#exists?(name, prefix = nil, partial = false) ⇒ Boolean Also known as: template_exists?
89 90 91 |
# File 'lib/action_view/lookup_context.rb', line 89 def exists?(name, prefix = nil, partial = false) @view_paths.exists?(*args_for_lookup(name, prefix, partial)) end |
#find(name, prefix = nil, partial = false) ⇒ Object Also known as: find_template
80 81 82 |
# File 'lib/action_view/lookup_context.rb', line 80 def find(name, prefix = nil, partial = false) @view_paths.find(*args_for_lookup(name, prefix, partial)) end |
#find_all(name, prefix = nil, partial = false) ⇒ Object
85 86 87 |
# File 'lib/action_view/lookup_context.rb', line 85 def find_all(name, prefix = nil, partial = false) @view_paths.find_all(*args_for_lookup(name, prefix, partial)) end |
#with_fallbacks ⇒ Object
Add fallbacks to the view paths. Useful in cases you are rendering a :file.
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/action_view/lookup_context.rb', line 95 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 |