Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.stripTags = String.prototype.stripTags.wrap(
- function(proceed, allowTags) {
- if (allowTags) {
- if (Object.isString(allowTags)) allowTags = $w(allowTags)
- this.gsub(/(<\/?\s*)([^\s>]+)(\s[^>]*)?>/, function(match) {
- if (allowTags.include(match[2].toLowerCase()))
- return match[1] + match[2] + match[3] + '>'
- })
- } else {
- // proceed using the original function
- return proceed();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment