diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-22 12:28:40 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-22 15:24:31 -0700 |
commit | 01129534cde293e3561dd7cc3cb5ae9ac3de9e8c (patch) | |
tree | b652a0d98cff4d8b9f2ef9b6e95fb234b8d54027 /actionpack/lib/action_controller/abstract | |
parent | e976c489e6416cdc4714721df78dd43dd6d13d99 (diff) | |
download | rails-01129534cde293e3561dd7cc3cb5ae9ac3de9e8c.tar.gz rails-01129534cde293e3561dd7cc3cb5ae9ac3de9e8c.tar.bz2 rails-01129534cde293e3561dd7cc3cb5ae9ac3de9e8c.zip |
Cleaned up the #render_to_body chain by extracting determining the templates to render to a separate hook point.
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r-- | actionpack/lib/action_controller/abstract/layouts.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/abstract/renderer.rb | 24 |
2 files changed, 15 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index 557d68d866..dec394a021 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -57,10 +57,6 @@ module AbstractController end end end - - def _render_template(template, options) - _action_view._render_template_from_controller(template, options[:_layout], options, options[:_partial]) - end private diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb index f2044a35ec..d7c68549e1 100644 --- a/actionpack/lib/action_controller/abstract/renderer.rb +++ b/actionpack/lib/action_controller/abstract/renderer.rb @@ -33,16 +33,12 @@ module AbstractController # # :api: plugin def render_to_body(options = {}) - name = options[:_template_name] || action_name - # TODO: Refactor so we can just use the normal template logic for this if options[:_partial_object] _action_view._render_partial_from_controller(options) - else - options[:_template] ||= view_paths.find_by_parts(name.to_s, {:formats => formats}, - options[:_prefix], options[:_partial]) - - _render_template(options[:_template], options) + else + _determine_template(options) + _render_template(options) end end @@ -56,8 +52,8 @@ module AbstractController AbstractController::Renderer.body_to_s(render_to_body(options)) end - def _render_template(template, options) - _action_view._render_template_from_controller(template, nil, options, options[:_partial]) + def _render_template(options) + _action_view._render_template_from_controller(options[:_template], options[:_layout], options, options[:_partial]) end def view_paths() _view_paths end @@ -74,6 +70,16 @@ module AbstractController end end + private + + def _determine_template(options) + name = (options[:_template_name] || action_name).to_s + + options[:_template] ||= view_paths.find_by_parts( + name, { :formats => formats }, options[:_prefix], options[:_partial] + ) + end + module ClassMethods def append_view_path(path) |