Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6652

Show
Ignore:
Timestamp:
05/02/07 22:30:41 (1 year ago)
Author:
david
Message:

Fixed that content_tag with a block will just return the result instead of concate it if not used in a ERb view #7857, #7432 [michael.niessner]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6649 r6652  
    11*SVN* 
     2 
     3* Fixed that content_tag with a block will just return the result instead of concate it if not used in a ERb view #7857, #7432 [michael.niessner] 
    24 
    35* Replace the current block/continuation filter chain handling by an implementation based on a simple loop.  #8226 [Stefan Kaes] 
  • trunk/actionpack/lib/action_view/helpers/tag_helper.rb

    r5857 r6652  
    4949          options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) 
    5050          content = capture(&block) 
    51           concat(content_tag_string(name, content, options), block.binding) 
     51          content_tag = content_tag_string(name, content, options) 
     52          block_is_within_action_view?(block) ? concat(content_tag, block.binding) : content_tag 
    5253        else 
    5354          content = content_or_options_with_block 
     
    99100          escaped.gsub(/&([a-z]+|(#\d+));/i) { "&#{$1};" } 
    100101        end 
     102         
     103        def block_is_within_action_view?(block) 
     104          eval("defined? _erbout", block.binding) 
     105        end 
    101106    end 
    102107  end 
  • trunk/actionpack/test/template/tag_helper_test.rb

    r6057 r6652  
    4848  end 
    4949   
     50  def test_content_tag_with_block_and_options_outside_of_action_view 
     51    assert_equal content_tag("a", "Create", :href => "create"), 
     52                 content_tag("a", "href" => "create") { "Create" }     
     53  end 
     54   
    5055  def test_cdata_section 
    5156    assert_equal "<![CDATA[<hello world>]]>", cdata_section("<hello world>")