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 112

attr_reader :view_paths, :html_fallback_for_js

#view_paths (rw)

[ GitHub ]

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

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.

[ GitHub ]

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

def view_paths=(paths)
  @view_paths = ActionView::PathSet.new(Array(paths))
end

Instance Method Details

#exists?(name, prefixes = [], partial = false, keys = [], options = {}) ⇒ Boolean Also known as: #template_exists?

[ GitHub ]

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

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 120

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 129

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

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

[ GitHub ]

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

def find_file(name, prefixes = [], partial = false, keys = [], options = {})
  @view_paths.find_file(*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 123

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 136

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 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