Guest User

Untitled

a guest
Oct 29th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. String.prototype.stripTags = String.prototype.stripTags.wrap(
  2. function(proceed, allowTags) {
  3. if (allowTags) {
  4. if (Object.isString(allowTags)) allowTags = $w(allowTags)
  5. this.gsub(/(<\/?\s*)([^\s>]+)(\s[^>]*)?>/, function(match) {
  6. if (allowTags.include(match[2].toLowerCase()))
  7. return match[1] + match[2] + match[3] + '>'
  8. })
  9. } else {
  10. // proceed using the original function
  11. return proceed();
  12. }
  13. });
Advertisement
Add Comment
Please, Sign In to add comment