diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-01 12:56:04 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-01 13:40:13 +0200 |
commit | b73576138529b1344a38f4e4b16c642f3510d514 (patch) | |
tree | af20defc605263df77a2bd22f50103a4c6eacf15 /actionpack/lib/action_view/renderer | |
parent | 367bdc53611fe1da9cedda3220a83d3f39409cff (diff) | |
download | rails-b73576138529b1344a38f4e4b16c642f3510d514.tar.gz rails-b73576138529b1344a38f4e4b16c642f3510d514.tar.bz2 rails-b73576138529b1344a38f4e4b16c642f3510d514.zip |
Introduce view renderer.
Diffstat (limited to 'actionpack/lib/action_view/renderer')
-rw-r--r-- | actionpack/lib/action_view/renderer/renderer.rb | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/actionpack/lib/action_view/renderer/renderer.rb b/actionpack/lib/action_view/renderer/renderer.rb index 582ed2f9f8..3c0126f6bb 100644 --- a/actionpack/lib/action_view/renderer/renderer.rb +++ b/actionpack/lib/action_view/renderer/renderer.rb @@ -10,21 +10,6 @@ module ActionView @controller = controller end - def render(context, options = {}, locals = {}, &block) - case options - when Hash - if block_given? - _render_partial(context, options.merge(:partial => options[:layout]), &block) - elsif options.key?(:partial) - _render_partial(context, options) - else - _render_template(context, options) - end - else - _render_partial(context, :partial => options, :locals => locals) - end - end - # Render but returns a valid Rack body. If fibers are defined, we return # a streaming body that renders the template piece by piece. # @@ -32,24 +17,26 @@ module ActionView # so in such cases, we just wrap them in an array. def render_body(context, options) if options.key?(:partial) - [_render_partial(context, options)] + [render_partial(context, options)] else StreamingTemplateRenderer.new(@lookup_context, @controller).render(context, options) end end - private - - def _render_template(context, options) #:nodoc: + # Direct accessor to template rendering. + def render_template(context, options) #:nodoc: _template_renderer.render(context, options) end - def _template_renderer #:nodoc: - @_template_renderer ||= TemplateRenderer.new(@lookup_context, @controller) + # Direct access to partial rendering. + def render_partial(context, options, &block) #:nodoc: + _partial_renderer.render(context, options, block) end - def _render_partial(context, options, &block) #:nodoc: - _partial_renderer.render(context, options, block) + private + + def _template_renderer #:nodoc: + @_template_renderer ||= TemplateRenderer.new(@lookup_context, @controller) end def _partial_renderer #:nodoc: |