Ticket #7432: content_tag_accepts_block_from_helper.diff
| File content_tag_accepts_block_from_helper.diff, 1.7 kB (added by cody, 2 years ago) |
|---|
-
test/template/tag_helper_test.rb
old new 36 36 end 37 37 38 38 def test_content_tag_with_block 39 _erbout = '' 40 content_tag(:div) { _erbout.concat "Hello world!" } 41 assert_dom_equal "<div>Hello world!</div>", _erbout 39 assert_dom_equal "<div>Hello world!</div>", content_tag(:div) { "Hello world!" } 42 40 end 43 41 44 42 def test_content_tag_with_block_and_options 45 _erbout = '' 46 content_tag(:div, :class => "green") { _erbout.concat "Hello world!" } 47 assert_dom_equal %(<div class="green">Hello world!</div>), _erbout 43 assert_dom_equal %(<div class="green">Hello world!</div>), content_tag(:div, :class => "green") { "Hello world!" } 48 44 end 49 45 50 46 def test_cdata_section -
lib/action_view/helpers/tag_helper.rb
old new 47 47 def content_tag(name, content_or_options_with_block = nil, options = nil, &block) 48 48 if block_given? 49 49 options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) 50 content = capture(&block) 51 concat(content_tag_string(name, content, options), block.binding) 50 content = block.call 52 51 else 53 52 content = content_or_options_with_block 54 content_tag_string(name, content, options)55 53 end 54 content_tag_string(name, content, options) 56 55 end 57 56 58 57 # Returns a CDATA section with the given +content+. CDATA sections