method
find_template
rails latest stable - Class:
ActionView::PathSet
find_template(original_template_path, format = nil, html_fallback = true)public
No documentation available.
# File actionpack/lib/action_view/paths.rb, line 43
def find_template(original_template_path, format = nil, html_fallback = true)
return original_template_path if original_template_path.respond_to?(:render)
template_path = original_template_path.sub(/^\//, '')
each do |load_path|
if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"])
return template
# Try the default locale version if the current locale doesn't have one
# (i.e. you haven't translated this view to German yet, but you have the English version on hand)
elsif format && (template = load_path["#{template_path}.#{I18n.default_locale}.#{format}"])
return template
elsif format && (template = load_path["#{template_path}.#{format}"])
return template
elsif template = load_path["#{template_path}.#{I18n.locale}"]
return template
elsif template = load_path["#{template_path}.#{I18n.default_locale}"]
return template
elsif template = load_path[template_path]
return template
# Try to find html version if the format is javascript
elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.locale}.html"]
return template
elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.default_locale}.html"]
return template
elsif format == :js && html_fallback && template = load_path["#{template_path}.html"]
return template
end
end
return Template.new(original_template_path) if File.file?(original_template_path)
raise MissingTemplate.new(self, original_template_path, format)
end