Tuesday, 13 August 2013

Remove whitespace from inside html tags

Remove whitespace from inside html tags

How can I remove whitespace from within html tags?
For example:
"\r\n\t This is a paragraph\r\n".strip
=> "This is a Paragraph"
But what about when:
"<p>\r\n\t This is a paragraph\r\n</p>".strip
=> "<p>\r\n\t This is a paragraph\r\n</p>"
How can I get ruby to remove the whitespace from inside the
tags (while retaining the p tags)?

No comments:

Post a Comment