<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -0,0 +1,14 @@
+6/22/2008:
+
+Erubis modified:
+* &lt;%= %&gt; now can take a block, so &lt;%= helper do %&gt;Hello&lt;% end %&gt; now works
+* Erubis buffer is now an ivar (@_erb_buf), which eliminates the need for
+  eval in capture helpers.
+  
+CONSEQUENCE:
+Helpers that take a block should simply return a string, and should not
+use concat. Example:
+  
+  def my_helper(&amp;blk)
+    &quot;My helper says #{capture(&amp;blk)}.&quot;
+  end
\ No newline at end of file</diff>
      <filename>PUBLIC_CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -4,16 +4,29 @@ require &quot;erubis&quot;
 module Erubis
   module BlockAwareEnhancer
     def add_preamble(src)
-      src &lt;&lt; &quot;@_buf = '';&quot;
-    end    
+      src &lt;&lt; &quot;_old_buf, @_erb_buf = @_erb_buf, ''; &quot;
+    end
+    
+    def add_postamble(src)
+      src &lt;&lt; &quot;\n&quot; unless src[-1] == ?\n      
+      src &lt;&lt; &quot;_ret = @_erb_buf; @_erb_buf = _old_buf; _ret.to_s\n&quot;
+    end
+    
+    def add_text(src, text)
+      src &lt;&lt; &quot; @_erb_buf &lt;&lt; '&quot; &lt;&lt; text &lt;&lt; &quot;'; &quot;
+    end
+    
+    def add_expr_escaped(src, code)
+      src &lt;&lt; ' @_erb_buf &lt;&lt; ' &lt;&lt; escaped_expr(code) &lt;&lt; ';'
+    end
     
     def add_expr_literal(src, code)
       unless code =~ /(do|\{)(\s*|[^|]*|)?\s*$/
-        src &lt;&lt; ' _buf &lt;&lt; (' &lt;&lt; code &lt;&lt; ').to_s;'
+        src &lt;&lt; ' @_erb_buf &lt;&lt; (' &lt;&lt; code &lt;&lt; ').to_s;'
       else
-        src &lt;&lt; ' _buf &lt;&lt; ' &lt;&lt; code &lt;&lt; &quot;; &quot;
+        src &lt;&lt; ' @_erb_buf &lt;&lt; ' &lt;&lt; code &lt;&lt; &quot;; &quot;
       end
-    end    
+    end
   end
   
   class BlockAwareEruby &lt; Eruby
@@ -22,21 +35,22 @@ module Erubis
 end
 
 class Context
-  def _buf
-    @_buf ||= &quot;&quot;
-  end
-
   def capture(&amp;blk)
-    _old_buf, @_buf = @_buf, &quot;&quot;
+    _old_buf, @_erb_buf = @_erb_buf, &quot;&quot;
     blk.call
-    ret = @_buf
-    @_buf = _old_buf
+    ret = @_erb_buf
+    @_erb_buf = _old_buf
     ret
   end
+  
+  def hello
+    &quot;Hello&quot;
+  end
 
   def helper(&amp;blk)
     &quot;&lt;tag&gt;#{capture(&amp;blk)}&lt;/tag&gt;&quot;
   end
 end
 
-p Erubis::BlockAwareEruby.new.process(&quot;Begin: &lt;%= helper do %&gt;Hello&lt;% end %&gt;&lt;% 3.times do %&gt;X&lt;% end %&gt;&quot;, Context.new)
\ No newline at end of file
+puts Erubis::BlockAwareEruby.new(&quot;Begin: &lt;%= helper do %&gt;Hello&lt;% end %&gt;&lt;% 3.times do %&gt;X&lt;% end %&gt;&lt;%= hello %&gt;&quot;).src
+p Erubis::BlockAwareEruby.new.process(&quot;Begin: &lt;%= helper do %&gt;Hello&lt;% end %&gt;&lt;% 3.times do %&gt;X&lt;% end %&gt;&lt;%= hello %&gt;&quot;, Context.new)
\ No newline at end of file</diff>
      <filename>experimentation/experiments/erubis.rb</filename>
    </modified>
    <modified>
      <diff>@@ -156,24 +156,13 @@ module Merb::Template
     # name&lt;String&gt;:: The name of the method that will be created.
     # mod&lt;Module&gt;:: The module that the compiled method will be placed into.
     def self.compile_template(io, name, mod)
-      template = ::Erubis::Eruby.new(io.read)
+      template = ::Erubis::BlockAwareEruby.new(io.read)
       template.def_method(mod, name, File.expand_path(io.path))
       name
     end
 
     module Mixin
       
-      # Provides direct acccess to the buffer for this view context
-      #
-      # ==== Parameters
-      # the_binding&lt;Binding&gt;:: The binding to pass to the buffer.
-      #
-      # ==== Returns
-      # DOC
-      def _erb_buffer( the_binding )
-        @_buffer = eval( &quot;_buf&quot;, the_binding, __FILE__, __LINE__)
-      end
-
       # ==== Parameters
       # *args:: Arguments to pass to the block.
       # &amp;block:: The template block to call.
@@ -188,30 +177,16 @@ module Merb::Template
       #     &lt;p&gt;Some Foo content!&lt;/p&gt; 
       #   &lt;% end %&gt;
       def capture_erb(*args, &amp;block)
-        # get the buffer from the block's binding
-        buffer = _erb_buffer( block.binding ) rescue nil
-
-        # If there is no buffer, just call the block and get the contents
-        if buffer.nil?
-          block.call(*args)
-        # If there is a buffer, execute the block, then extract its contents
-        else
-          pos = buffer.length
-          block.call(*args)
-
-          # extract the block
-          data = buffer[pos..-1]
-
-          # replace it in the original with empty string
-          buffer[pos..-1] = ''
-
-          data
-        end
+        _old_buf, @_erb_buf = @_erb_buf, &quot;&quot;
+        block.call
+        ret = @_erb_buf
+        @_erb_buf = _old_buf
+        ret
       end
 
       # DOC
       def concat_erb(string, binding)
-        _erb_buffer(binding) &lt;&lt; string
+        @_erb_buf &lt;&lt; string
       end
             
     end
@@ -222,14 +197,46 @@ module Merb::Template
 end
 
 module Erubis
-  module RubyEvaluator
+  module BlockAwareEnhancer
+    def add_preamble(src)
+      src &lt;&lt; &quot;_old_buf, @_erb_buf = @_erb_buf, ''; &quot;
+      src &lt;&lt; &quot;@_engine = 'erb'; &quot;
+    end
 
-    # DOC
-    def def_method(object, method_name, filename=nil)
-      m = object.is_a?(Module) ? :module_eval : :instance_eval
-      setup = &quot;@_engine = 'erb'&quot;
-      object.__send__(m, &quot;def #{method_name}(locals={}); #{setup}; #{@src}; end&quot;, filename || @filename || '(erubis)')
+    def add_postamble(src)
+      src &lt;&lt; &quot;\n&quot; unless src[-1] == ?\n      
+      src &lt;&lt; &quot;_ret = @_erb_buf; @_erb_buf = _old_buf; _ret.to_s\n&quot;
+    end
+
+    def add_text(src, text)
+      src &lt;&lt; &quot; @_erb_buf &lt;&lt; '&quot; &lt;&lt; escape_text(text) &lt;&lt; &quot;'; &quot;
+    end
+
+    def add_expr_escaped(src, code)
+      src &lt;&lt; ' @_erb_buf &lt;&lt; ' &lt;&lt; escaped_expr(code) &lt;&lt; ';'
+    end
+
+    def add_expr_literal(src, code)
+      unless code =~ /(do|\{)(\s*|[^|]*|)?\s*$/
+        src &lt;&lt; ' @_erb_buf &lt;&lt; (' &lt;&lt; code &lt;&lt; ').to_s;'
+      else
+        src &lt;&lt; ' @_erb_buf &lt;&lt; ' &lt;&lt; code &lt;&lt; &quot;; &quot;
+      end
     end
-   
   end
+
+  class BlockAwareEruby &lt; Eruby
+    include BlockAwareEnhancer
+  end
+  
+  # module RubyEvaluator
+  # 
+  #   # DOC
+  #   def def_method(object, method_name, filename=nil)
+  #     m = object.is_a?(Module) ? :module_eval : :instance_eval
+  #     setup = &quot;@_engine = 'erb'&quot;
+  #     object.__send__(m, &quot;def #{method_name}(locals={}); #{setup}; #{@src}; end&quot;, filename || @filename || '(erubis)')
+  #   end
+  #  
+  # end
 end
\ No newline at end of file</diff>
      <filename>lib/merb-core/controller/template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,11 +7,18 @@ module Merb::Test::Fixtures
       def _template_location(context, type = nil, controller = controller_name)
         &quot;helpers/#{File.basename(controller)}/#{context}&quot;
       end
+      
+      def index
+        render
+      end
     end
     
     class Capture &lt; HelperTesting
-      def index
-        render
+    end
+    
+    class CaptureEq &lt; HelperTesting
+      def helper_using_capture(&amp;blk)
+        &quot;Beginning... #{capture(&amp;blk)}... Done&quot;
       end
     end
 </diff>
      <filename>spec/public/abstract_controller/controllers/helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,9 +5,13 @@ describe Merb::AbstractController, &quot; with capture and concat&quot; do
   it &quot;should support capture&quot; do
     dispatch_should_make_body(&quot;Capture&quot;, &quot;Capture&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
   
   it &quot;should support concat&quot; do
     dispatch_should_make_body(&quot;Concat&quot;, &quot;Concat&quot;)
   end
-  
+    
 end</diff>
      <filename>spec/public/abstract_controller/helper_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0e44eca7bd69e325b687d2174f054ece61910ad0</id>
    </parent>
  </parents>
  <author>
    <name>Yehuda Katz</name>
    <email>wycats@gmail.com</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/7043503871759eadc947bc5138ebbc96b8e17d74</url>
  <id>7043503871759eadc947bc5138ebbc96b8e17d74</id>
  <committed-date>2008-06-22T18:37:13-07:00</committed-date>
  <authored-date>2008-06-22T18:37:13-07:00</authored-date>
  <message>&lt;%= now takes a block in Erubis. Erubis buffer now an ivar (@_erb_buf) so eval is no longer required for capture. Helpers that take a block should now return a string.</message>
  <tree>28d5d1835e98962007a98e671ae73df979014a2a</tree>
  <committer>
    <name>Yehuda Katz</name>
    <email>wycats@gmail.com</email>
  </committer>
</commit>
