diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 10 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 9 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/_partial_only.rhtml | 1 |
4 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 581668f19b..ec67d80fb2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added that render_partial called from a controller will use the action name as default #828 [Dan Peterson] + * Added Element.toggle, Element.show, and Element.hide to the prototype javascript library. Toggle.display has been deprecated, but will still work #992 [Lucas Carlson] * Added that deleting a cookie should not just set it to an empty string but also instantly expire it #1118 [todd@robotcoop.com] diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index c8a012afda..15724e2e36 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -489,11 +489,19 @@ module ActionController #:nodoc: @template.render_file(template_name) end - def render_partial(partial_path, object = nil, local_assigns = {}) #:doc: + # Renders the partial specified by <tt>partial_path</tt>, which by default is the name of the action itself. Example: + # + # class WeblogController < ActionController::Base + # def show + # render_partial # renders "weblog/_show.r(xml|html)" + # end + # end + def render_partial(partial_path = default_template_name, object = nil, local_assigns = {}) #:doc: add_variables_to_assigns render_text(@template.render_partial(partial_path, object, local_assigns)) end + # Renders a collection of partials using <tt>partial_name</tt> to iterate over the +collection+. def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = {})#:doc: add_variables_to_assigns render_text(@template.render_collection_of_partials(partial_name, collection, partial_spacer_template, local_assigns)) diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index e471139d8f..fd3e08177a 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -59,6 +59,10 @@ class TestController < ActionController::Base render_action "list" end + def partial_only + render_partial + end + def hello_in_a_string @customers = [ Customer.new("david"), Customer.new("mary") ] render_text "How's there? #{render_to_string("test/list")}" @@ -181,6 +185,11 @@ class RenderTest < Test::Unit::TestCase assert_equal "Hello: davidHello: mary", process_request.body end + def test_partial_only + @request.action = "partial_only" + assert_equal "only partial", process_request.body + end + def test_render_to_string @request.action = "hello_in_a_string" assert_equal "How's there? Hello: davidHello: mary", process_request.body diff --git a/actionpack/test/fixtures/test/_partial_only.rhtml b/actionpack/test/fixtures/test/_partial_only.rhtml new file mode 100644 index 0000000000..a44b3eed40 --- /dev/null +++ b/actionpack/test/fixtures/test/_partial_only.rhtml @@ -0,0 +1 @@ +only partial
\ No newline at end of file |