From ab8642c9daaac9db65f67ee85e10e8baa7d60ff8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 23 Feb 2005 15:26:48 +0000 Subject: Added Base#render_component_as_string git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@769 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/components.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb index 3a8fbb97ee..0374a56c10 100644 --- a/actionpack/lib/action_controller/components.rb +++ b/actionpack/lib/action_controller/components.rb @@ -5,21 +5,18 @@ module ActionController #:nodoc: super base.helper do def render_component(options) - @controller.logger.info("Start rendering component (#{options.inspect}): ") unless @controller.logger.nil? - result = @controller.send(:component_response, options, false).body - @controller.logger.info("\n\nEnd of component rendering") unless @controller.logger.nil? - return result + @controller.send(:render_component_as_string, options) end end end protected def render_component(options = {}) #:doc: - response = component_response(options) - logger.info("Start rendering component (#{options.inspect}): ") unless logger.nil? - result = render_text(response.body, response.headers["Status"]) - logger.info("\n\nEnd of component rendering") unless logger.nil? - return result + component_logging(options) { render_text(component_response(options).body, response.headers["Status"]) } + end + + def render_component_as_string(options) #:doc: + component_logging(options) { component_response(options, false).body } end private @@ -43,5 +40,12 @@ module ActionController #:nodoc: def response_for_component @response.dup end + + def component_logging(options) + logger.info("Start rendering component (#{options.inspect}): ") unless logger.nil? + result = yield + logger.info("\n\nEnd of component rendering") unless logger.nil? + return result + end end end -- cgit v1.2.3