Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Base#render_component_as_string

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@769 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ab8642c9daaac9db65f67ee85e10e8baa7d60ff8 1 parent f9fca1e
David Heinemeier Hansson dhh authored
Showing with 13 additions and 9 deletions.
  1. +13 −9 actionpack/lib/action_controller/components.rb
22 actionpack/lib/action_controller/components.rb
View
@@ -5,21 +5,18 @@ def self.append_features(base)
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 @@ def request_for_component(options)
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
Please sign in to comment.
Something went wrong with that request. Please try again.