aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/rendering.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2019-02-13 17:59:21 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2019-02-19 13:46:09 -0800
commit1bc0a59d6ee198fa535c04f32527a1d6228b647d (patch)
treebbdbd9cdef5aebd1878df4ee54b1f6e2cd534ebd /actionview/lib/action_view/rendering.rb
parentd0733ba8c0528aa4bc6e890e189afaac62ebe58f (diff)
downloadrails-1bc0a59d6ee198fa535c04f32527a1d6228b647d.tar.gz
rails-1bc0a59d6ee198fa535c04f32527a1d6228b647d.tar.bz2
rails-1bc0a59d6ee198fa535c04f32527a1d6228b647d.zip
Return rendered template information instead of just strings
This commit introduces "rendered template" and "rendered collection" objects. The template renderers can now return a more complex object than just strings. This allows the framework to get more information about the templates that were rendered. In this commit we use the rendered template object to set the "rendered_format" on the lookup context in the controller rather than all the way in the template renderer. That means we don't need to check the "rendered_format" every time we render a template, we just do it once after all templates have been rendered.
Diffstat (limited to 'actionview/lib/action_view/rendering.rb')
-rw-r--r--actionview/lib/action_view/rendering.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb
index b798e80b04..699ccb0ca8 100644
--- a/actionview/lib/action_view/rendering.rb
+++ b/actionview/lib/action_view/rendering.rb
@@ -109,10 +109,15 @@ module ActionView
context = view_context
context.assign assigns if assigns
- lookup_context.rendered_format = nil if options[:formats]
lookup_context.variants = variant if variant
- context.view_renderer.render(context, options)
+ rendered_template = context.in_rendering_context(options) do |renderer|
+ renderer.render_to_object(context, options)
+ end
+
+ lookup_context.rendered_format = rendered_template.format || lookup_context.formats.first
+
+ rendered_template.body
end
# Assign the rendered format to look up context.