aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/renderer/template_renderer.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-09-22 15:03:05 +0200
committerJosé Valim <jose.valim@gmail.com>2011-09-22 15:03:05 +0200
commit119e9e2dafb0cdc5b85613b730333679aef534af (patch)
treed2d26382e4f606a5c13d7c76cd48ed3f57f11b36 /actionpack/lib/action_view/renderer/template_renderer.rb
parentcbaad674f13067c52fa8c1a24dc498e570db4eed (diff)
downloadrails-119e9e2dafb0cdc5b85613b730333679aef534af.tar.gz
rails-119e9e2dafb0cdc5b85613b730333679aef534af.tar.bz2
rails-119e9e2dafb0cdc5b85613b730333679aef534af.zip
Get rid of update_details in favor of passing details to find_template.
Diffstat (limited to 'actionpack/lib/action_view/renderer/template_renderer.rb')
-rw-r--r--actionpack/lib/action_view/renderer/template_renderer.rb27
1 files changed, 12 insertions, 15 deletions
diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb
index 0a5b470a82..f3e7378f2b 100644
--- a/actionpack/lib/action_view/renderer/template_renderer.rb
+++ b/actionpack/lib/action_view/renderer/template_renderer.rb
@@ -4,30 +4,28 @@ require 'active_support/core_ext/array/wrap'
module ActionView
class TemplateRenderer < AbstractRenderer #:nodoc:
def render(context, options)
- @view = context
-
- wrap_formats(options[:template] || options[:file]) do
- template = determine_template(options)
- freeze_formats(template.formats, true)
- render_template(template, options[:layout], options[:locals])
- end
+ @view = context
+ @details = options.slice(:formats, :locale, :handlers)
+ extract_format(options[:file] || options[:template], @details)
+ template = determine_template(options)
+ freeze_formats(template.formats, true)
+ render_template(template, options[:layout], options[:locals])
end
# Determine the template to be rendered using the given options.
def determine_template(options) #:nodoc:
- keys = options[:locals].try(:keys) || []
- details = options.slice(:formats, :locale, :handlers)
+ keys = options[:locals].try(:keys) || []
if options.key?(:text)
Template::Text.new(options[:text], formats.try(:first))
elsif options.key?(:file)
- with_fallbacks { find_template(options[:file], nil, false, keys, details) }
+ with_fallbacks { find_template(options[:file], nil, false, keys, @details) }
elsif options.key?(:inline)
handler = Template.handler_for_extension(options[:type] || "erb")
Template.new(options[:inline], "inline template", handler, :locals => keys)
elsif options.key?(:template)
options[:template].respond_to?(:render) ?
- options[:template] : find_template(options[:template], options[:prefixes], false, keys)
+ options[:template] : find_template(options[:template], options[:prefixes], false, keys, @details)
end
end
@@ -63,12 +61,11 @@ module ActionView
begin
with_layout_format do
layout =~ /^\// ?
- with_fallbacks { find_template(layout, nil, false, keys) } : find_template(layout, nil, false, keys)
+ with_fallbacks { find_template(layout, nil, false, keys, @details) } : find_template(layout, nil, false, keys, @details)
end
rescue ActionView::MissingTemplate
- update_details(:formats => nil) do
- raise unless template_exists?(layout)
- end
+ all_details = @details.merge(:formats => @lookup_context.default_formats)
+ raise unless template_exists?(layout, nil, false, keys, all_details)
end
end
end