rails 过滤掉所有的html标签 strip_tags

 

 
strip_tags(html)

Strips all HTML tags from the html, including comments. This usesthe html-scanner tokenizer and so its HTML parsing ability is limited bythat of html-scanner.

Examples

  strip_tags("Strip <i>these</i> tags!")
  # => Strip these tags!

  strip_tags("<b>Bold</b> no more!  <a href='more.html'>See more here</a>...")
  # => Bold no more!  See more here...

  strip_tags("<div id='top-bar'>Welcome to my website!</div>")
  # => Welcome to my website!


一般用于 view  层
posted @ 2013-08-03 23:30  wangyuyu  阅读(795)  评论(0编辑  收藏  举报