Sha256: e2684789db8da691d1e0b0fdd1cd46e2c3be4477f9129b71459a18acda83200b

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

##
## $Rev: 21 $
## $Release: 2.0.0 $
## copyright(c) 2006 kuwata-lab all rights reserved.
##


module Erubis

  ##
  ## helper for xml
  ##
  module XmlHelper

    module_function

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

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

    #--
    #def escape_xml(obj)
    #  str = obj.to_s.dup
    #  #str = obj.to_s
    #  #str = str.dup if obj.__id__ == str.__id__
    #  str.gsub!(/&/, '&amp;')
    #  str.gsub!(/</, '&lt;')
    #  str.gsub!(/>/, '&gt;')
    #  str.gsub!(/"/, '&quot;')
    #  str.gsub!(/'/, '&#039;')
    #  return str
    #end
    #++

    alias h escape_xml
    alias html_escape escape_xml

  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erubis-2.0.0 lib/erubis/helper.rb