<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,15 +9,6 @@ $LOAD_PATH.unshift File.dirname(__FILE__) unless
   $LOAD_PATH.include?(File.dirname(__FILE__)) ||
   $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
 
-require 'merb-core/autoload'
-require 'merb-core/server'
-require 'merb-core/core_ext'
-require 'merb-core/gem_ext/erubis'
-require 'merb-core/logger'
-require 'merb-core/version'
-require 'merb-core/controller/mime'
-require 'merb-core/vendor/facets'
-
 begin
   require &quot;json/ext&quot;
 rescue LoadError
@@ -174,3 +165,11 @@ module Merb
   end
 
 end
+
+require 'merb-core/autoload'
+require 'merb-core/server'
+require 'merb-core/gem_ext/erubis'
+require 'merb-core/logger'
+require 'merb-core/version'
+require 'merb-core/controller/mime'
+require 'merb-core/vendor/facets'</diff>
      <filename>lib/merb-core.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,6 @@ module Merb
   autoload :Cookies,              &quot;merb-core/dispatch/cookies&quot;
   autoload :Dispatcher,           &quot;merb-core/dispatch/dispatcher&quot;
   autoload :ErubisCaptureMixin,   &quot;merb-core/controller/mixins/erubis_capture&quot;
-  autoload :Hook,                 &quot;merb-core/hook&quot;
   autoload :Plugins,              &quot;merb-core/plugins&quot;
   autoload :Rack,                 &quot;merb-core/rack&quot;
   autoload :RenderMixin,          &quot;merb-core/controller/mixins/render&quot;
@@ -21,6 +20,8 @@ end
 
 # Require this rather than autoloading it so we can be sure the default template
 # gets registered
+require 'merb-core/core_ext'
+require 'merb-core/hook'
 require &quot;merb-core/controller/template&quot;
 require &quot;merb-core/hook&quot;
 </diff>
      <filename>lib/merb-core/autoload.rb</filename>
    </modified>
    <modified>
      <diff>@@ -71,7 +71,7 @@ class Merb::AbstractController
   include Merb::InlineTemplates
   is_hookable
   
-  class_inheritable_accessor :_before_filters, :_after_filters, :_template_root, :_layout
+  class_inheritable_accessor :_before_filters, :_after_filters, :_layout, :_template_root
 
   # Controller name is part of the public API
   def self.controller_name() @controller_name ||= self.name.to_const_path end
@@ -116,7 +116,6 @@ class Merb::AbstractController
   # own subclasses. We're using a Set so we don't have to worry about
   # uniqueness.
   self._abstract_subclasses = Set.new
-  self._template_root = Merb.dir_for(:view)
 
   def self.subclasses_list() _abstract_subclasses end
   
@@ -125,8 +124,11 @@ class Merb::AbstractController
     # klass&lt;Merb::AbstractController&gt;::
     #   The controller that is being inherited from Merb::AbstractController
     def inherited(klass)
-      _abstract_subclasses &lt;&lt; klass.to_s
-      klass.send(:include, Object.full_const_get(&quot;Merb::#{klass}Helper&quot;)) rescue nil
+      _abstract_subclasses &lt;&lt; klass.to_s   
+      self._template_root = Merb.dir_for(:view) unless self._template_root       
+      klass.class_eval &lt;&lt;-HERE
+        include Object.full_const_get(&quot;Merb::#{klass}Helper&quot;) rescue nil
+      HERE
       super
     end
     
@@ -153,6 +155,7 @@ class Merb::AbstractController
   def initialize(*args)
     @_benchmarks = {}
     @_caught_content = {}
+    @_template_stack = []
   end
   
   # This will dispatch the request, calling before and after dispatch hooks
@@ -376,6 +379,10 @@ class Merb::AbstractController
     opts[:exclude]  = Array(opts[:exclude]).map {|x| x.to_s} if opts[:exclude]
     return opts
   end
+  
+  def capture(*args, &amp;block)
+    send(&quot;capture_#{@_engine}&quot;, *args, &amp;block)
+  end
 
   def method_missing(sym, *args, &amp;blk)
     return @_merb_partial_locals[sym] if @_merb_partial_locals &amp;&amp; @_merb_partial_locals.key?(sym)</diff>
      <filename>lib/merb-core/controller/abstract_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -62,9 +62,11 @@ module Merb::RenderMixin
       template_location = _template_root / (opts[:template] || _template_location(thing, content_type))
       
       # Get the method name from the previously inlined list
-      template_method = Merb::Template.template_for(template_location)
+      template_method = _template_for(template_location)
 
       # Raise an error if there's no template
+      require 'ruby-debug'
+      debugger if $DEBUG
       raise TemplateNotFound, &quot;No template found at #{template_location}&quot; unless 
         template_method &amp;&amp; self.respond_to?(template_method)
 
@@ -145,7 +147,7 @@ module Merb::RenderMixin
       # Look for the layout under the default layout directly. If it's not found, reraise
       # the TemplateNotFound error
       template = _template_location(opts[:layout], layout.index(&quot;.&quot;) ? content_type : nil, &quot;layout&quot;)      
-      layout = Merb::Template.template_for(_template_root / template) ||
+      layout = _template_for(_template_root / template) ||
         (raise TemplateNotFound, &quot;No layout found at #{_template_root / template}.*&quot;)      
               
       # If the layout was found, call it
@@ -196,7 +198,7 @@ module Merb::RenderMixin
     template_location = _template_root / _template_location(template, content_type, kontroller)
     
     # Get the method name from the previously inlined list
-    template_method = Merb::Template.template_for(template_location)    
+    template_method = _template_for(template_location)
 
     if opts.key?(:with)
       with = opts.delete(:with)
@@ -257,16 +259,20 @@ module Merb::RenderMixin
     # If a layout was provided, throw an error if it's not found
     if layout
       template = _template_location(layout, layout.index(&quot;.&quot;) ? nil : content_type, &quot;layout&quot;)      
-      Merb::Template.template_for(_template_root / template) ||
+      _template_for(_template_root / template) ||
         (raise TemplateNotFound, &quot;No layout found at #{_template_root / template}.*&quot;)
     
     # If a layout was not provided, try the default locations
     else
-      Merb::Template.template_for(_template_root / _template_location(controller_name, content_type, &quot;layout&quot;)) ||
-      Merb::Template.template_for(_template_root / _template_location(&quot;application&quot;, content_type, &quot;layout&quot;)) || nil
+      _template_for(_template_root / _template_location(controller_name, content_type, &quot;layout&quot;)) ||
+      _template_for(_template_root / _template_location(&quot;application&quot;, content_type, &quot;layout&quot;)) || nil
     end    
   end
   
+  def _template_for(path)
+    Merb::Template.template_for(path)
+  end
+    
   # Called in templates to get at content thrown in another template.
   # The results of rendering a template are automatically thrown
   # into :layout, so catch_content or catch_content(:layout) can be</diff>
      <filename>lib/merb-core/controller/mixins/render.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,6 @@
+module Merb::InlineTemplates
+end
+
 module Merb::Template
   
   EXTENSIONS  = {} unless defined?(EXTENSIONS)
@@ -28,14 +31,21 @@ module Merb::Template
     # path&lt;String&gt;:: A full path to find a template method for
     #---
     # @semipublic
-    def template_for(path)
+    def template_for(path, template_stack = [])
       path = File.expand_path(path)
-      file = Dir[&quot;#{path}.{#{Merb::Template::EXTENSIONS.keys.join(',')}}&quot;].first      
+      
+      ret = 
       if Merb::Config[:reload_templates]
+        file = Dir[&quot;#{path}.{#{Merb::Template::EXTENSIONS.keys.join(',')}}&quot;].first
         METHOD_LIST[path] = file ? inline_template(file) : nil
       else
-        METHOD_LIST[path] ||= file ? inline_template(file) : nil        
+        METHOD_LIST[path] ||= begin
+          file = Dir[&quot;#{path}.{#{Merb::Template::EXTENSIONS.keys.join(',')}}&quot;].first          
+          file ? inline_template(file) : nil
+        end
       end
+      
+      ret
     end
     
     # Takes a template at a particular path and inlines it into
@@ -90,6 +100,9 @@ module Merb::Template
       raise ArgumentError, &quot;The class you are registering does not have a compile_template method&quot; unless
         engine.respond_to?(:compile_template)
       extensions.each{|ext| EXTENSIONS[ext] = engine }
+      Merb::AbstractController.class_eval &lt;&lt;-HERE
+        include #{engine}::Mixin
+      HERE
     end
   end
   
@@ -103,13 +116,13 @@ module Merb::Template
     def self.compile_template(path, name, mod)
       template = ::Erubis::Eruby.new(File.read(path))
       template.def_method(mod, name, path) 
-      name     
+      name
     end
 
     module Mixin
       
       # Provides direct acccess to the buffer for this view context
-      def _buffer( the_binding )
+      def _erb_buffer( the_binding )
         @_buffer = eval( &quot;_buf&quot;, the_binding, __FILE__, __LINE__)
       end
 
@@ -122,9 +135,9 @@ module Merb::Template
       #   &lt;% @foo = capture do %&gt;
       #     &lt;p&gt;Some Foo content!&lt;/p&gt; 
       #   &lt;% end %&gt;
-      def capture(*args, &amp;block)
+      def capture_erb(*args, &amp;block)
         # get the buffer from the block's binding
-        buffer = _buffer( block.binding ) rescue nil
+        buffer = _erb_buffer( block.binding ) rescue nil
 
         # If there is no buffer, just call the block and get the contents
         if buffer.nil?
@@ -142,11 +155,27 @@ module Merb::Template
 
           data
         end
-      end  
+      end
+      
+      def concat_erb(string, binding)
+        _erb_buffer(binding) &lt;&lt; string
+      end
             
     end
   
     Merb::Template.register_extensions(self, %w[erb])    
   end
   
+end
+
+module Erubis
+  module RubyEvaluator
+  
+    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}; #{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>@@ -1,21 +1,23 @@
-class Merb::SimpleSet &lt; Hash
+module Merb
+  class SimpleSet &lt; Hash
 
-  def initialize(arr = [])
-    arr.each {|x| self[x] = true}
-  end
+    def initialize(arr = [])
+      arr.each {|x| self[x] = true}
+    end
 
-  def &lt;&lt;(value)
-    self[value] = true
-  end
+    def &lt;&lt;(value)
+      self[value] = true
+    end
 
-  def merge(arr)
-    super(arr.inject({}) {|s,x| s[x] = true; s })
-  end
+    def merge(arr)
+      super(arr.inject({}) {|s,x| s[x] = true; s })
+    end
 
-  def inspect
-    &quot;#&lt;SimpleSet: {#{keys.map {|x| x.inspect}.join(&quot;, &quot;)}}&gt;&quot;
-  end
+    def inspect
+      &quot;#&lt;SimpleSet: {#{keys.map {|x| x.inspect}.join(&quot;, &quot;)}}&gt;&quot;
+    end
   
-  alias_method :to_a, :keys
-
+    alias_method :to_a, :keys
+    
+  end
 end
\ No newline at end of file</diff>
      <filename>lib/merb-core/core_ext/set.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,16 +8,16 @@ hsh = {:x =&gt; true, :y =&gt; true}
 set = Set.new([:x, :y])
 fst = FasterSet.new([:x, :y])
 
-# Benchmark.bmbm do |x|
-#   x.report(&quot;current included&quot;) { TIMES.times { hsh[:x] } }
-#   x.report(&quot;hash included&quot;) { TIMES.times { hsh.include?(:x) } }
-#   x.report(&quot;set included&quot;) { TIMES.times { set.include?(:x) } }  
-#   x.report(&quot;fasterset included&quot;) { TIMES.times { fst.include?(:x) } }  
-#   x.report(&quot;current !included&quot;) { TIMES.times { hsh[:z] } }  
-#   x.report(&quot;hash !included&quot;) { TIMES.times { hsh.include?(:z) } }
-#   x.report(&quot;set !included&quot;) { TIMES.times { set.include?(:z) } }    
-#   x.report(&quot;fasterset !included&quot;) { TIMES.times { fst.include?(:z) } }      
-# end
+Benchmark.bmbm do |x|
+  x.report(&quot;current included&quot;) { TIMES.times { hsh[:x] } }
+  x.report(&quot;hash included&quot;) { TIMES.times { hsh.include?(:x) } }
+  x.report(&quot;set included&quot;) { TIMES.times { set.include?(:x) } }  
+  x.report(&quot;fasterset included&quot;) { TIMES.times { fst.include?(:x) } }  
+  x.report(&quot;current !included&quot;) { TIMES.times { hsh[:z] } }  
+  x.report(&quot;hash !included&quot;) { TIMES.times { hsh.include?(:z) } }
+  x.report(&quot;set !included&quot;) { TIMES.times { set.include?(:z) } }    
+  x.report(&quot;fasterset !included&quot;) { TIMES.times { fst.include?(:z) } }      
+end
 
 # TIMES = 1_000_000
 #                           user     system      total        real</diff>
      <filename>simple_benches/set_hash.rb</filename>
    </modified>
    <modified>
      <diff>@@ -42,6 +42,9 @@ module Merb::Test::Fixtures
         end
       EOS
     end
+    
+    module Mixin
+    end
   end
 
   module MyHelpers</diff>
      <filename>spec/public/template/template_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a952c9895541975ee64689782f9a6023e9416f28</id>
    </parent>
  </parents>
  <author>
    <name>Yehuda Katz</name>
    <email>wycats@gmail.com</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/3d023b06e4da0bfc9edbb28ee92fd2bec762b31a</url>
  <id>3d023b06e4da0bfc9edbb28ee92fd2bec762b31a</id>
  <committed-date>2008-02-18T19:19:26-08:00</committed-date>
  <authored-date>2008-02-18T19:19:26-08:00</authored-date>
  <message>Fixes for capture/concat</message>
  <tree>6249c26c22c40bbe8dc6953e55d7382a290622ec</tree>
  <committer>
    <name>Yehuda Katz</name>
    <email>wycats@gmail.com</email>
  </committer>
</commit>
