Changeset 1009

Show
Ignore:
Timestamp:
11/16/07 01:36:39 (1 year ago)
Author:
e.@brainspl.at
Message:

fixing up fieldset helper. closes #311

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/merb_helpers/Rakefile

    r1007 r1009  
    44PLUGIN = "merb_helpers" 
    55NAME = "merb_helpers" 
    6 VERSION = "0.4.1" 
     6GEM_VERSION = "0.4.1" 
    77AUTHOR = "Yehuda Katz" 
    88EMAIL = "wycats@gmail.com" 
     
    1212spec = Gem::Specification.new do |s| 
    1313  s.name = NAME 
    14   s.version = VERSION 
     14  s.version = GEM_VERSION 
    1515  s.platform = Gem::Platform::RUBY 
    1616  s.has_rdoc = true 
  • plugins/merb_helpers/lib/form_helpers.rb

    r1006 r1009  
    3535    # 
    3636    #     <form action="/foo/bar/1" method="post"> 
    37     #       <input id="first_name" name="first_name" size="30" type="text" /> 
     37    #       <label for="first_name">First Name</label><input id="first_name" name="first_name" size="30" type="text" /> 
    3838    #       <input name="commit" type="submit" value="Create" /> 
    3939    #     </form> 
     
    8181      # 
    8282      #     <form action="/foo/bar/1" method="post"> 
    83       #       <input id="first_name" name="first_name" size="30" type="text" /> 
     83      #       <label for="first_name">First Name</label><input id="first_name" name="first_name" size="30" type="text" /> 
    8484      #       <input name="commit" type="submit" value="Create" /> 
    8585      #     </form> 
     
    103103      # 
    104104      #     <form action="/people/create" method="post"> 
    105       #       <input id="person_first_name" name="person[first_name]" size="30" type="text" /> 
    106       #       <input id="person_last_name" name="person[last_name]" size="30" type="text" /> 
     105      #       <label for="person[first_name]">First Name</label><input id="person_first_name" name="person[first_name]" size="30" type="text" /> 
     106      #       <label for="person[last_name]">Last Name</label><input id="person_last_name" name="person[last_name]" size="30" type="text" /> 
    107107      #       <input name="commit" type="submit" value="Create" /> 
    108108      #     </form> 
     
    392392      # ==== Options 
    393393      # +legend+:: The name of this fieldset which will be provided in a HTML legend tag. 
    394       def fieldset(attrs = {}, &block) 
     394      def fieldset(attrs={}, &block) 
    395395        legend = attrs.delete(:legend) 
    396         open_tag( 'fieldset', attrs ) + ( tag('legend', legend) if legend ) + yield + "</fieldset>" 
    397       end 
    398  
     396        concat( open_tag('fieldset', attrs), block.binding ) 
     397        concat( tag('legend', legend), block.binding ) if legend 
     398        concat(capture(&block), block.binding) 
     399        concat( "</fieldset>", block.binding) 
     400      end 
     401       
    399402      ## file input control 
    400403      def file_control(col, attrs = {}) 
  • plugins/merb_helpers/specs/merb_helpers_spec.rb

    r1006 r1009  
    512512 
    513513  it "should provide legend option" do 
    514     form_tag do 
     514    fieldset :legend => 'TEST' do 
    515515      _buffer << "CONTENT" 
    516516    end 
    517     _buffer.should match_tag(:form, :method => "post") 
    518517    _buffer.should include("CONTENT") 
     518    _buffer.should match_tag(:fieldset, {}) 
     519    _buffer.should match_tag(:legend, :content => 'TEST') 
    519520  end 
    520521end