Class: MarkupAttr::Sanitize

Inherits:
Object
  • Object
show all
Extended by:
ActionView::Helpers::SanitizeHelper::ClassMethods
Includes:
ActionView::Helpers::SanitizeHelper, Singleton
Defined in:
lib/markup_attr/sanitize.rb

Overview

Use ActionView sanitizer class to strip out HTML in simple contained class.

Class Method Summary collapse

Class Method Details

.html(text, options = {}) ⇒ Object

Strip html from text. You can specify allowed tags and attributes by setting the options :tags and :attributes.

Sanitize.html(text, {
  :tags => %w[a li p ul ol code pre em strong],
  :attributes => %w[href]
})

Setting :tags and :attributes to nil will accept everything.



28
29
30
# File 'lib/markup_attr/sanitize.rb', line 28

def self.html(text, options = {})
  instance.sanitize(text, options)
end

.strip_tags(text) ⇒ Object

Strip all html.



12
13
14
# File 'lib/markup_attr/sanitize.rb', line 12

def self.strip_tags(text)
  instance.strip_tags(text)
end