Sha256: a7c192d64c5312c715c25040e5b72c31771e4073284a5e588b99b08e6b0eefc5

Contents?: true

Size: 862 Bytes

Versions: 13

Compression:

Stored size: 862 Bytes

Contents

##
## $Rev: 89 $
## $Release: 2.6.2 $
## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
##


module Erubis

  ##
  ## helper for xml
  ##
  module XmlHelper

    module_function

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

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

    def escape_xml2(value)
      return value.to_s.gsub(/\&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;').gsub(/"/,'&quot;')
    end

    alias h escape_xml
    alias html_escape escape_xml

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

    alias u url_encode

  end


end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/lib/erubis/helper.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/lib/erubis/helper.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/lib/erubis/helper.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/lib/erubis/helper.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/lib/erubis/helper.rb
simple-templater-0.0.1.3 vendor/erubis/lib/erubis/helper.rb
simple-templater-0.0.1.2 vendor/erubis/lib/erubis/helper.rb
simple-templater-0.0.1.1 vendor/erubis/lib/erubis/helper.rb
rango-0.0.6 vendor/erubis/lib/erubis/helper.rb
rango-0.1.pre vendor/erubis/lib/erubis/helper.rb
simple-templater-0.0.1 vendor/erubis/lib/erubis/helper.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/lib/erubis/helper.rb
erubis-2.6.2 lib/erubis/helper.rb