<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/examples/yield/1/setup.rb</filename>
    </added>
    <added>
      <filename>spec/examples/yield/2/2_1/b.erb</filename>
    </added>
    <added>
      <filename>spec/examples/yield/2/2_1/setup.rb</filename>
    </added>
    <added>
      <filename>spec/examples/yield/2/2_2/c.erb</filename>
    </added>
    <added>
      <filename>spec/examples/yield/2/2_2/setup.rb</filename>
    </added>
    <added>
      <filename>spec/examples/yield/2/a.erb</filename>
    </added>
    <added>
      <filename>spec/examples/yield/2/setup.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -103,10 +103,7 @@ module Tadpole
     def initialize(opts = {}, &amp;block)
       self.options = opts
       @providers = {}
-      #self.sections(*sections)
       
-      init(&amp;block)
-
       if Tadpole.caching
         @compiled_sections = compile_sections(sections) 
       end
@@ -116,8 +113,11 @@ module Tadpole
 
     def run(opts = {}, &amp;block)
       return '' if run_before_run.is_a?(FalseClass)
-      
-      run_sections(@compiled_sections || sections, false, opts, &amp;block)
+
+      with_options(opts) do
+        init
+        run_sections(@compiled_sections || sections, &amp;block)
+      end
     rescue =&gt; e
       begin
         provider = find_section_provider(current_section)
@@ -135,25 +135,25 @@ module Tadpole
     alias to_s run
     
     def run_sections(sects, break_first = false, locals = {}, &amp;block)
-      with_locals(locals) do
+      with_options(locals) do
         out = ''
         raise ArgumentError, &quot;Template(#{path}) is missing sections&quot; unless sects
         sects = sects.first if sects.first.is_a?(Array)
         sects.each_with_index do |section, i|
           (break_first ? break : next) if section.is_a?(Array)
-        
+      
           self.current_section = section_name(section)
-        
+      
           next if run_before_sections.is_a?(FalseClass)
 
           if sects[i+1].is_a?(Array)
             old, self.subsections = subsections, sects[i+1]
-            out += run_subsections(section, sects[i+1], locals, &amp;block)
+            out += run_subsections(section, sects[i+1], &amp;block)
             self.subsections = old
           else
-            out += render(section, locals, true, &amp;block)
+            out += render(section, {}, true, &amp;block)
           end
-        
+      
           break if break_first
         end
         out
@@ -192,21 +192,23 @@ module Tadpole
     end
     
     def render(section, locals = {}, call_method = false, &amp;block)
-      case section
-      when String, Symbol
-        if call_method &amp;&amp; respond_to?(section) 
-          send(section, &amp;block)
+      with_options(locals) do
+        case section
+        when String, Symbol
+          if call_method &amp;&amp; respond_to?(section) 
+            send(section, &amp;block)
+          else
+            find_section_provider(section).render(options, &amp;block)
+          end
+        when Template
+          section.run(options, &amp;block)
+        when Module
+          section.new(options).run(&amp;block)
+        when SectionProviders::SectionProvider
+          section.render(options, &amp;block)
         else
-          find_section_provider(section).render(locals, &amp;block)
+          raise MissingSectionError, &quot;missing section #{section.inspect}&quot;
         end
-      when Template
-        section.run(locals, &amp;block)
-      when Module
-        section.new(options).run(locals, &amp;block)
-      when SectionProviders::SectionProvider
-        section.render(locals, &amp;block)
-      else
-        raise MissingSectionError, &quot;missing section #{section.inspect}&quot;
       end
     end
 
@@ -237,7 +239,7 @@ module Tadpole
       end
     end
     
-    def with_locals(locals = {}, &amp;block)
+    def with_options(locals = {}, &amp;block)
       old_options = options
       self.options = options.to_hash.merge(locals)
       result = yield</diff>
      <filename>lib/tadpole/template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,11 @@ describe Tadpole, '::Template' do
     Tadpole.register_template_path File.dirname(__FILE__) + '/examples' 
   end
   
-  it &quot;should yield with extra values&quot; do
-    Template('yield').new.run.should == '[FOOBARBAR]'
+  it &quot;should yield to a method with extra values&quot; do
+    Template('yield/1').new.run.should == '[FOOBARBAR]'
+  end
+  
+  it &quot;should yield to external template with extra values&quot; do
+    Template('yield/2').new(:foo =&gt; 'FOO').run.should == 'BARBAR'
   end
 end</diff>
      <filename>spec/yield_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>spec/examples/yield/setup.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>983b8bd3595dedfe325abbe29fd0befae9694eb4</id>
    </parent>
  </parents>
  <author>
    <name>Loren Segal</name>
    <email>lsegal@soen.ca</email>
  </author>
  <url>http://github.com/lsegal/tadpole/commit/ff8beb293edd9dcb1b1251bca399256f4b7c3fc8</url>
  <id>ff8beb293edd9dcb1b1251bca399256f4b7c3fc8</id>
  <committed-date>2009-08-14T18:01:25-07:00</committed-date>
  <authored-date>2009-08-14T18:01:25-07:00</authored-date>
  <message>Add specs for yielding extra options</message>
  <tree>2a1f216053518aef3047395c93bc6b523c2679aa</tree>
  <committer>
    <name>Loren Segal</name>
    <email>lsegal@soen.ca</email>
  </committer>
</commit>
