aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-31 02:09:06 +0100
committerYehuda Katz <wycats@Yehuda-Katz.local>2009-12-31 18:40:20 -0800
commit50aa876f3276aabfac16aea90ba5f6b45b4cbffc (patch)
treed847e58ae43235a212a06666461023c8c08e0431
parentc03c40b481f433214ff68d1cae93df9e26190b42 (diff)
downloadrails-50aa876f3276aabfac16aea90ba5f6b45b4cbffc.tar.gz
rails-50aa876f3276aabfac16aea90ba5f6b45b4cbffc.tar.bz2
rails-50aa876f3276aabfac16aea90ba5f6b45b4cbffc.zip
Make rendering in ActionView happen through _render_template, as the rendering which comes from ActionController.
-rw-r--r--actionpack/lib/action_view/render/rendering.rb44
1 files changed, 14 insertions, 30 deletions
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb
index 0302e44b4e..48316cac53 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/render/rendering.rb
@@ -22,15 +22,18 @@ module ActionView
return _render_partial(options)
end
- layout = find(layout, {:formats => formats}) if layout
+ template = if options[:file]
+ find(options[:file], {:formats => formats})
+ elsif options[:inline]
+ handler = Template.handler_class_for_extension(options[:type] || "erb")
+ Template.new(options[:inline], "inline template", handler, {})
+ elsif options[:text]
+ Template::Text.new(options[:text])
+ end
- if file = options[:file]
- template = find(file, {:formats => formats})
+ if template
+ layout = find(layout, {:formats => formats}) if layout
_render_template(template, layout, :locals => options[:locals])
- elsif inline = options[:inline]
- _render_inline(inline, layout, options)
- elsif text = options[:text]
- _render_text(text, layout, options[:locals])
end
when :update
update_page(&block)
@@ -76,42 +79,23 @@ module ActionView
capture(&block)
end
- def _render_inline(inline, layout, options)
- locals = options[:locals]
-
- content = ActiveSupport::Notifications.instrument(:render_inline) do
- handler = Template.handler_class_for_extension(options[:type] || "erb")
- template = Template.new(options[:inline], "inline template", handler, {})
- template.render(self, locals)
- end
-
- _render_text(content, layout, locals)
- end
-
- def _render_text(content, layout, locals)
- ActiveSupport::Notifications.instrument(:render_text)
- content = _render_layout(layout, locals){ content } if layout
- content
- end
-
# This is the API to render a ViewContext's template from a controller.
#
# Internal Options:
# _template:: The Template object to render
# _layout:: The layout, if any, to wrap the Template in
- # _partial:: true if the template is a partial
def render_template(options)
_evaluate_assigns_and_ivars
- template, layout, partial = options.values_at(:_template, :_layout, :_partial)
- _render_template(template, layout, options, partial)
+ template, layout = options.values_at(:_template, :_layout)
+ _render_template(template, layout, options)
end
- def _render_template(template, layout = nil, options = {}, partial = nil)
+ def _render_template(template, layout = nil, options = {})
locals = options[:locals] || {}
content = ActiveSupport::Notifications.instrument(:render_template,
:identifier => template.identifier, :layout => (layout ? layout.identifier : nil)) do
- partial ? _render_partial_object(template, options) : template.render(self, locals)
+ template.render(self, locals)
end
@_content_for[:layout] = content