On Tue, May 30, 2006 at 03:51:47AM +0100, Jim C. wrote:
On Mon, May 29, 2006 at 07:42:41PM -0700, Zack H. wrote:
Is there a common way of stripping html tags from a string? Right now I’m just
calling gsub!(/<.*?>/, ‘’), but with a background in PHP and always having used
its strip_tags() method, I wonder if the Rails community has standardized this
fairly common task with something a bit less simpleminded than my quick fix.
Suspect you want the erb html_escape method
Or I suspect that I should actually read what you wrote …
http://www.php.net/manual/en/function.strip-tags.php describes the php
strip_tags, and points out a number of interesting problems that it
might have under some circumstances, and a few good workarounds.
Simply gsubbing the <…> instances away isn’t quite the same as
rendering the document, but I can’t see anything that does that. I guess
finding a “nicer” replacement depends on your source data, and what
you’re trying to achieve …