module Hesburgh::Lib::HtmlScrubber

Exposes a consistent means of scrubbing HTML.

@see Rails `sanitize` method @todo Extract to the Hesburgh::Lib gem

Constants

ALLOWED_BLOCK_ATTRIBUTES
ALLOWED_INLINE_ATTRIBUTES
ALLOWED_INLINE_TAGS

Public Class Methods

build_block_scrubber() click to toggle source

We are allowing multiple lines of content. Examples include an “abstract” of an item

# File lib/hesburgh/lib/html_scrubber.rb, line 32
def self.build_block_scrubber
  AllowedTagsScrubber.new(tags: AllowedTagsScrubber::FALLBACK, attributes: ALLOWED_BLOCK_ATTRIBUTES)
end
build_inline_scrubber(tags: ALLOWED_INLINE_TAGS, attributes: ALLOWED_INLINE_ATTRIBUTES) click to toggle source

We expect a single line of content. Examples include a “title” of an item

# File lib/hesburgh/lib/html_scrubber.rb, line 22
def self.build_inline_scrubber(tags: ALLOWED_INLINE_TAGS, attributes: ALLOWED_INLINE_ATTRIBUTES)
  AllowedTagsScrubber.new(tags: tags, attributes: attributes)
end
build_meta_tag_scrubber(tags: [], attributes: :fallback) click to toggle source

We want to render this information as part of the metadata of a page. Examples include the `html head title` attribute

# File lib/hesburgh/lib/html_scrubber.rb, line 17
def self.build_meta_tag_scrubber(tags: [], attributes: :fallback)
  AllowedTagsScrubber.new(tags: tags, attributes: attributes)
end