aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-07 01:51:50 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-07 01:51:50 -0300
commit8534c5bf193c6a234d55116d520a54a1b634a93e (patch)
treeee3c604e911759f8f3962d7c7ea9d5c906b61eb5 /actionpack
parent9b506484f1e72aeba2f1fd4af3e39cf450f1d4a9 (diff)
downloadrails-8534c5bf193c6a234d55116d520a54a1b634a93e.tar.gz
rails-8534c5bf193c6a234d55116d520a54a1b634a93e.tar.bz2
rails-8534c5bf193c6a234d55116d520a54a1b634a93e.zip
Start cleaning up partial path
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/abstract_controller/renderer.rb4
-rw-r--r--actionpack/lib/action_controller/metal/renderer.rb2
-rw-r--r--actionpack/lib/action_view/render/partials.rb10
-rw-r--r--actionpack/lib/action_view/render/rendering.rb16
4 files changed, 20 insertions, 12 deletions
diff --git a/actionpack/lib/abstract_controller/renderer.rb b/actionpack/lib/abstract_controller/renderer.rb
index 4e368a099a..73e6b2a4dc 100644
--- a/actionpack/lib/abstract_controller/renderer.rb
+++ b/actionpack/lib/abstract_controller/renderer.rb
@@ -54,7 +54,7 @@ module AbstractController
# :api: plugin
def render_to_body(options = {})
# TODO: Refactor so we can just use the normal template logic for this
- if options[:_partial_object]
+ if options.key?(:_partial_object)
view_context.render_partial(options)
else
_determine_template(options)
@@ -77,7 +77,7 @@ module AbstractController
# _layout<ActionView::Template>:: The layout to wrap the template in (optional)
# _partial<TrueClass, FalseClass>:: Whether or not the template to be rendered is a partial
def _render_template(options)
- view_context.render_template(options[:_template], options[:_layout], options, options[:_partial])
+ view_context.render_template(options)
end
# The list of view paths for this controller. See ActionView::ViewPathSet for
diff --git a/actionpack/lib/action_controller/metal/renderer.rb b/actionpack/lib/action_controller/metal/renderer.rb
index 572da451ff..5a458764ad 100644
--- a/actionpack/lib/action_controller/metal/renderer.rb
+++ b/actionpack/lib/action_controller/metal/renderer.rb
@@ -57,7 +57,7 @@ module ActionController
when true
options[:_prefix] = _prefix
when String
- options[:_prefix] = _prefix unless partial.index('/')
+ options[:_prefix] = _prefix unless partial.include?(?/)
options[:_template_name] = partial
else
options[:_partial_object] = true
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb
index 3e60dcf068..89d954037b 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/render/partials.rb
@@ -183,12 +183,12 @@ module ActionView
end
end
- def render_partial(*args)
+ def render_partial(options)
@assigns_added = false
- _render_partial(*args)
+ _render_partial(options)
end
- def _render_partial(options = {}) #:nodoc:
+ def _render_partial(options) #:nodoc:
options[:locals] ||= {}
path = partial = options[:partial]
@@ -244,7 +244,9 @@ module ActionView
array_like
end
- def _render_partial_object(template, options, object = nil)
+ def _render_partial_object(template, options)
+ object = options[:object]
+
if options.key?(:collection)
_render_partial_collection(options.delete(:collection), options, template)
else
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb
index 86a59dd1bc..32c30e8f68 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/render/rendering.rb
@@ -123,19 +123,25 @@ module ActionView
layout ? _render_content_with_layout(text, layout, options[:locals]) : text
end
- def render_template(*args)
+ # 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)
@assigns_added = nil
- _render_template_with_layout(*args)
+ template, layout, partial = options.values_at(:_template, :_layout, :_partial)
+ _render_template_with_layout(template, layout, options, partial)
end
- def _render_template_with_layout(template, layout = nil, options = {}, partial = false)
+ def _render_template_with_layout(template, layout = nil, options = {}, partial = nil)
logger && logger.info("Rendering #{template.identifier}#{' (#{options[:status]})' if options[:status]}")
locals = options[:locals] || {}
content = if partial
- object = partial unless partial == true
- _render_partial_object(template, options, object)
+ _render_partial_object(template, options)
else
_render_template(template, locals)
end