Module: Erubis::XmlHelper

Module | Erubis::XmlHelper
In: | erubis/helper.rb

helper for xml

### Methods

escape_xml escape_xml2 h html_escape u url_encode

### Constants

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

### Public Instance methods

escape_xml(value)

[Source]

    # File erubis/helper.rb, line 24
        def escape_xml(value)
          value.to_s.gsub(/[&<>"]/) { |s| ESCAPE_TABLE[s] }   # or /[&<>"']/
          #value.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] }
        end

escape_xml2(value)

[Source]

    # File erubis/helper.rb, line 29
        def escape_xml2(value)
          return value.to_s.gsub(/\&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;').gsub(/"/,'&quot;')
        end

h(value)

Alias for escape_xml

html_escape(value)

Alias for escape_xml

u(str)

Alias for url_encode

url_encode(str)

[Source]

    # File erubis/helper.rb, line 36
        def url_encode(str)
          return str.gsub(/[^-_.a-zA-Z0-9]+/) { |s|
            s.unpack('C*').collect { |i| "%%%02X" % i }.join
          }
        end

[Validate]