<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/public/abstract_controller/controllers/views/helpers/capture_non_string_return_value/index.erb</filename>
    </added>
    <added>
      <filename>spec/public/abstract_controller/controllers/views/helpers/capture_return_value/index.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -477,12 +477,22 @@ class Merb::AbstractController
   #
   # ==== Parameters
   # *args:: Arguments to pass to the block.
-  # &amp;block:: The template block to call.
+  # &amp;block:: The block to call.
   #
   # ==== Returns
-  # String:: The output of the block.
+  # String:: The output of a template block or the return value of a non-template block converted to a string.
   def capture(*args, &amp;block)
-    send(&quot;capture_#{@_engine}&quot;, *args, &amp;block)
+    ret = nil
+
+    captured = send(&quot;capture_#{@_engine}&quot;, *args) do |*args|
+      ret = yield *args
+    end
+
+    if captured.empty?
+      ret.to_s
+    else
+      captured
+    end
   end
 
   # Calls the concatenate method for the selected template engine.</diff>
      <filename>lib/merb-core/controller/abstract_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,12 @@ module Merb::Test::Fixtures
     class CaptureWithArgs &lt; HelperTesting
     end
     
+    class CaptureReturnValue &lt; HelperTesting
+    end
+
+    class CaptureNonStringReturnValue &lt; HelperTesting
+    end
+
     class CaptureEq &lt; HelperTesting
       def helper_using_capture(&amp;blk)
         &quot;Beginning... #{capture(&amp;blk)}... Done&quot;</diff>
      <filename>spec/public/abstract_controller/controllers/helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,14 @@ describe Merb::AbstractController, &quot; with capture and concat&quot; do
     dispatch_should_make_body(&quot;CaptureWithArgs&quot;, &quot;Capture: one, two&quot;)
   end
 
+  it &quot;should support capturing the return value of a non-template block&quot; do
+    dispatch_should_make_body(&quot;CaptureReturnValue&quot;, &quot;Capture&quot;)
+  end
+
+  it &quot;should support capturing the return value of a non-template block&quot; do
+    dispatch_should_make_body(&quot;CaptureNonStringReturnValue&quot;, &quot;Captured ''&quot;)
+  end
+
   it &quot;should support basic helpers that use capture with &lt;%=&quot; do
     dispatch_should_make_body(&quot;CaptureEq&quot;, &quot;Pre. Beginning... Capturing... Done. Post.&quot;)
   end</diff>
      <filename>spec/public/abstract_controller/helper_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>15ac66c1907732d254765c67551be42ef4a76d61</id>
    </parent>
  </parents>
  <author>
    <name>Drew Colthorp</name>
    <email>colthorp@atomicobject.com</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/03ff7c4957115750d6802b9dee969be14a4b3057</url>
  <id>03ff7c4957115750d6802b9dee969be14a4b3057</id>
  <committed-date>2008-09-27T23:05:35-07:00</committed-date>
  <authored-date>2008-09-24T18:58:52-07:00</authored-date>
  <message>capture returns return value of passed in block if it is not a template block

Signed-off-by: Michael S. Klishin &lt;michael@novemberain.com&gt;</message>
  <tree>ace4ba2fc9e4d656eed17a208a3aece8757d6aba</tree>
  <committer>
    <name>Michael S. Klishin</name>
    <email>michael@novemberain.com</email>
  </committer>
</commit>
