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

Instance Method Summary collapse

Instance Attribute Details

#html_fallback_for_jsObject (readonly)

Returns the value of attribute html_fallback_for_js.



107
108
109
# File 'lib/action_view/lookup_context.rb', line 107

def html_fallback_for_js
  @html_fallback_for_js
end

#view_pathsObject

Returns the value of attribute view_paths.



107
108
109
# File 'lib/action_view/lookup_context.rb', line 107

def view_paths
  @view_paths
end

Instance Method Details

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

Returns:

  • (Boolean)


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

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?

Returns:

  • (Boolean)


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

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 = {}) ⇒ Object Also known as: find_template



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

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 = {}) ⇒ Object



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

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 = {}) ⇒ Object



120
121
122
# File 'lib/action_view/lookup_context.rb', line 120

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

#with_fallbacksObject

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



140
141
142
143
144
145
146
147
148
149
150
# File '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