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
-
#html_fallback_for_js ⇒ Object
readonly
Returns the value of attribute html_fallback_for_js.
-
#view_paths ⇒ Object
readonly
Returns the value of attribute view_paths.
Instance Method Summary collapse
- #any?(name, prefixes = [], partial = false) ⇒ Boolean (also: #any_templates?)
- #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
Adds fallbacks to the view paths.
Instance Attribute Details
#html_fallback_for_js ⇒ Object (readonly)
Returns the value of attribute html_fallback_for_js.
124 125 126 |
# File 'lib/action_view/lookup_context.rb', line 124 def html_fallback_for_js @html_fallback_for_js end |
#view_paths ⇒ Object (readonly)
Returns the value of attribute view_paths.
124 125 126 |
# File 'lib/action_view/lookup_context.rb', line 124 def view_paths @view_paths end |
Instance Method Details
#any?(name, prefixes = [], partial = false) ⇒ Boolean Also known as: any_templates?
140 141 142 |
# File 'lib/action_view/lookup_context.rb', line 140 def any?(name, prefixes = [], partial = false) @view_paths.exists?(*args_for_any(name, prefixes, partial)) end |
#exists?(name, prefixes = [], partial = false, keys = [], **options) ⇒ Boolean Also known as: template_exists?
135 136 137 |
# File 'lib/action_view/lookup_context.rb', line 135 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
126 127 128 |
# File 'lib/action_view/lookup_context.rb', line 126 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
131 132 133 |
# File 'lib/action_view/lookup_context.rb', line 131 def find_all(name, prefixes = [], partial = false, keys = [], = {}) @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, )) end |
#with_fallbacks ⇒ Object
Adds fallbacks to the view paths. Useful in cases when you are rendering a :file.
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/action_view/lookup_context.rb', line 147 def with_fallbacks view_paths = build_view_paths((@view_paths.paths + self.class.fallbacks).uniq) if block_given? raise ArgumentError, <<~eowarn.squish Calling `with_fallbacks` with a block is not supported. Call methods on the lookup context returned by `with_fallbacks` instead. eowarn else ActionView::LookupContext.new(view_paths, @details, @prefixes) end end |