Module: Erubis::XmlHelper

Defined in:
lib/erubis/helper.rb

Overview

helper for xml

Constant Summary collapse

ESCAPE_TABLE =
{
  '&' => '&',
  '<' => '&lt;',
  '>' => '&gt;',
  '"' => '&quot;',
  "'" => '&#039;',
}

Class Method Summary collapse

Class Method Details

.escape_xml(value) ⇒ Object Also known as: h, html_escape



25
26
27
28
# File 'lib/erubis/helper.rb', line 25

def escape_xml(value)
  value.to_s.gsub(/[&<>"]/) { |s| ESCAPE_TABLE[s] }   # or /[&<>"']/
  #value.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] }
end