Module: Innate::Helper::CGI

Defined in:
lib/innate/helper/cgi.rb

Class Method Summary collapse

Class Method Details

.html_and_code_escape(input) ⇒ Object Also known as: h

safely escape all HTML and code



45
46
47
# File 'lib/innate/helper/cgi.rb', line 45

def html_and_code_escape(input)
  Rack::Utils.escape_html(input.to_s).gsub(/#([{@$]@?)/, '#\1')
end

.html_escape(input) ⇒ String

Shortcut for Rack::Utils.escape_html

Parameters:

  • input (#to_s)

Returns:

  • (String)


32
33
34
# File 'lib/innate/helper/cgi.rb', line 32

def html_escape(input)
  Rack::Utils.escape_html(input.to_s)
end

.html_unescape(input) ⇒ String

Shortcut for CGI.unescapeHTML

Parameters:

  • input (#to_s)

Returns:

  • (String)


40
41
42
# File 'lib/innate/helper/cgi.rb', line 40

def html_unescape(input)
  ::CGI.unescapeHTML(input.to_s)
end

.url_decode(input) ⇒ String

Shortcut for Rack::Utils.unescape

Parameters:

  • input (#to_s)

Returns:

  • (String)

    URI-decoded representation of input



24
25
26
# File 'lib/innate/helper/cgi.rb', line 24

def url_decode(input)
  Rack::Utils.unescape(input.to_s)
end

.url_encode(input) ⇒ String Also known as: u

Shortcut for Rack::Utils.escape

Parameters:

  • input (#to_s)

Returns:

  • (String)

    URI-encoded representation of input



15
16
17
# File 'lib/innate/helper/cgi.rb', line 15

def url_encode(input)
  Rack::Utils.escape(input.to_s)
end