跳至内容 跳至搜索

Helpers 与使用查找上下文信息进行模板查找相关。

方法
A
D
E
F
P
T

属性

[R] html_fallback_for_js
[R] view_paths

实例公共方法

any?(name, prefixes = [], partial = false)

也称为: any_templates?
# File actionview/lib/action_view/lookup_context.rb, line 148
def any?(name, prefixes = [], partial = false)
  name, prefixes = normalize_name(name, prefixes)
  details, details_key = detail_args_for_any
  @view_paths.exists?(name, prefixes, partial, details, details_key, [])
end

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

别名: any?

append_view_paths(paths)

# File actionview/lib/action_view/lookup_context.rb, line 155
def append_view_paths(paths)
  @view_paths = build_view_paths(@view_paths.to_a + paths)
end

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

也称为: template_exists?
# File actionview/lib/action_view/lookup_context.rb, line 141
def exists?(name, prefixes = [], partial = false, keys = [], **options)
  name, prefixes = normalize_name(name, prefixes)
  details, details_key = detail_args_for(options)
  @view_paths.exists?(name, prefixes, partial, details, details_key, keys)
end

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

也称为: find_template
# File actionview/lib/action_view/lookup_context.rb, line 128
def find(name, prefixes = [], partial = false, keys = [], options = {})
  name, prefixes = normalize_name(name, prefixes)
  details, details_key = detail_args_for(options)
  @view_paths.find(name, prefixes, partial, details, details_key, keys)
end

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

# File actionview/lib/action_view/lookup_context.rb, line 135
def find_all(name, prefixes = [], partial = false, keys = [], options = {})
  name, prefixes = normalize_name(name, prefixes)
  details, details_key = detail_args_for(options)
  @view_paths.find_all(name, prefixes, partial, details, details_key, keys)
end

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

别名: find

prepend_view_paths(paths)

# File actionview/lib/action_view/lookup_context.rb, line 159
def prepend_view_paths(paths)
  @view_paths = build_view_paths(paths + @view_paths.to_a)
end

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

别名: exists?

实例私有方法

detail_args_for(options)

根据用户选项(例如从渲染传递)计算详细信息哈希和键。

# File actionview/lib/action_view/lookup_context.rb, line 175
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