Module: ActionView::LookupContext::ViewPaths
Relationships & Source Files | |
Defined in: | actionview/lib/action_view/lookup_context.rb |
Overview
::ActionView::Helpers
related to template lookup using the lookup context information.
Instance Attribute Summary
- #html_fallback_for_js readonly
- #view_paths rw
-
#view_paths=(paths)
rw
Whenever setting view paths, makes a copy so that we can manipulate them in instance objects as we wish.
Instance Method Summary
- #any?(name, prefixes = [], partial = false) ⇒ Boolean (also: #any_templates?)
-
#any_templates?(name, prefixes = [], partial = false)
Alias for #any?.
- #exists?(name, prefixes = [], partial = false, keys = [], **options) ⇒ Boolean (also: #template_exists?)
- #find(name, prefixes = [], partial = false, keys = [], options = {}) (also: #find_template)
- #find_all(name, prefixes = [], partial = false, keys = [], options = {})
- #find_file(name, prefixes = [], partial = false, keys = [], options = {})
-
#find_template(name, prefixes = [], partial = false, keys = [], options = {})
Alias for #find.
-
#template_exists?(name, prefixes = [], partial = false, keys = [], **options)
Alias for #exists?.
-
#with_fallbacks
Adds fallbacks to the view paths.
-
#detail_args_for(options)
private
Compute details hash and key according to user options (e.g.
Instance Attribute Details
#html_fallback_for_js (readonly)
[ GitHub ]# File 'actionview/lib/action_view/lookup_context.rb', line 107
attr_reader :view_paths, :html_fallback_for_js
#view_paths (rw)
[ GitHub ]# File 'actionview/lib/action_view/lookup_context.rb', line 107
attr_reader :view_paths, :html_fallback_for_js
#view_paths=(paths) (rw)
Whenever setting view paths, makes a copy so that we can manipulate them in instance objects as we wish.
# File 'actionview/lib/action_view/lookup_context.rb', line 111
def view_paths=(paths) @view_paths = ActionView::PathSet.new(Array(paths)) end
Instance Method Details
#any?(name, prefixes = [], partial = false) ⇒ Boolean
Also known as: #any_templates?
#any_templates?(name, prefixes = [], partial = false)
Alias for #any?.
# File 'actionview/lib/action_view/lookup_context.rb', line 136
alias :any_templates? :any?
#detail_args_for(options) (private)
Compute details hash and key according to user options (e.g. passed from #render
).
# File 'actionview/lib/action_view/lookup_context.rb', line 161
def detail_args_for( ) # :doc: return @details, details_key if .empty? # most common path. user_details = @details.merge( ) if @cache details_key = DetailsKey.get(user_details) else details_key = nil end [user_details, details_key] end
#exists?(name, prefixes = [], partial = false, keys = [], **options) ⇒ Boolean
Also known as: #template_exists?
#find(name, prefixes = [], partial = false, keys = [], options = {}) Also known as: #find_template
[ GitHub ]#find_all(name, prefixes = [], partial = false, keys = [], options = {})
[ GitHub ]#find_file(name, prefixes = [], partial = false, keys = [], options = {})
[ GitHub ]#find_template(name, prefixes = [], partial = false, keys = [], options = {})
Alias for #find.
# File 'actionview/lib/action_view/lookup_context.rb', line 118
alias :find_template :find
#template_exists?(name, prefixes = [], partial = false, keys = [], **options)
Alias for #exists?.
# File 'actionview/lib/action_view/lookup_context.rb', line 131
alias :template_exists? :exists?
#with_fallbacks
Adds fallbacks to the view paths. Useful in cases when you are rendering a :file
.
# File 'actionview/lib/action_view/lookup_context.rb', line 140
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