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

Changeset 4916

Show
Ignore:
Timestamp:
09/03/06 16:47:05 (2 years ago)
Author:
bitsweat
Message:

strip_tags returns nil for a blank arg such as nil or "". Closes #2229.

Files:

Legend:

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

    r4915 r4916  
    11*SVN* 
     2 
     3* strip_tags returns nil for a blank arg such as nil or "".  #2229 [duncan@whomwah.com] 
    24 
    35* Cleanup assert_tag :children counting.  #2181 [jamie@bravenet.com] 
  • trunk/actionpack/lib/action_view/helpers/text_helper.rb

    r4911 r4916  
    214214      # 
    215215      # Returns the tag free text. 
    216       def strip_tags(html) 
     216      def strip_tags(html)      
     217        return nil if html.blank? 
    217218        if html.index("<") 
    218219          text = "" 
  • trunk/actionpack/test/template/text_helper_test.rb

    r4911 r4916  
    315315    %{This is a test.\n\n\nIt no longer contains any HTML.\n}, strip_tags( 
    316316    %{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n})) 
    317     assert_equal("This has a  here.", strip_tags("This has a <!-- comment --> here.")
    318   end 
    319  
     317    assert_equal "This has a  here.", strip_tags("This has a <!-- comment --> here."
     318    [nil, '', '   '].each { |blank| assert_nil strip_tags(blank) } 
     319  end 
    320320end