123456789_123456789_123456789_123456789_123456789_

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

Instance Method Summary

Instance Attribute Details

#html_fallback_for_js (readonly)

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 124

attr_reader :view_paths, :html_fallback_for_js

#view_paths (readonly)

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 124

attr_reader :view_paths, :html_fallback_for_js

Instance Method Details

#any?(name, prefixes = [], partial = false) ⇒ Boolean Also known as: #any_templates?

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 140

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

#any_templates?(name, prefixes = [], partial = false)

Alias for #any?.

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 143

alias :any_templates? :any?

#detail_args_for(options) (private)

Compute details hash and key according to user options (e.g. passed from #render).

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 174

def detail_args_for(options) # :doc:
  return @details, details_key if options.empty? # most common path.
  user_details = @details.merge(options)

  if @cache
    details_key = DetailsKey.details_cache_key(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?

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 135

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

#find(name, prefixes = [], partial = false, keys = [], options = {}) Also known as: #find_template

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 126

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

#find_all(name, prefixes = [], partial = false, keys = [], options = {})

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 131

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

#find_template(name, prefixes = [], partial = false, keys = [], options = {})

Alias for #find.

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 129

alias :find_template :find

#template_exists?(name, prefixes = [], partial = false, keys = [], **options)

Alias for #exists?.

[ GitHub ]

  
# File 'actionview/lib/action_view/lookup_context.rb', line 138

alias :template_exists? :exists?

#with_fallbacks

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

[ GitHub ]

  
# File 'actionview/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