Module: Philiprehberger::HtmlBuilder::Escape
- Defined in:
- lib/philiprehberger/html_builder/escape.rb
Overview
HTML entity escaping utilities
Constant Summary collapse
- ENTITIES =
{ '&' => '&', '<' => '<', '>' => '>', '"' => '"', "'" => ''' }.freeze
- ENTITY_PATTERN =
Regexp.union(ENTITIES.keys).freeze
Class Method Summary collapse
-
.html(value) ⇒ String
Escape HTML special characters in a string.
Class Method Details
.html(value) ⇒ String
Escape HTML special characters in a string
21 22 23 |
# File 'lib/philiprehberger/html_builder/escape.rb', line 21 def self.html(value) value.to_s.gsub(ENTITY_PATTERN, ENTITIES) end |