
The StripHtml function strips all the HTML tags in the passed string but preserves the ones specified in the PreserveTags array.
def StripHtml(str, PreserveTags = ['a','img','p','br','i','b','u','ul','li']) | |
str = str.strip || '' | |
PreserveArr = PreserveTags.join('|') << '|\/' | |
str.gsub(/<(\/|\s)*[^(#{PreserveArr})][^>]*>/,'') | |
end |
No comments:
Post a Comment