Class: MarkupAttr::Sanitize
- Inherits:
-
Object
- Object
- MarkupAttr::Sanitize
- 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
-
.html(text, options = {}) ⇒ Object
Strip html from text.
-
.strip_tags(text) ⇒ Object
Strip all html.
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, = {}) instance.sanitize(text, ) end |
.strip_tags(text) ⇒ Object
Strip all html.
12 13 14 |
# File 'lib/markup_attr/sanitize.rb', line 12 def self.(text) instance.(text) end |