Sha256: c467974cf3ad9bab4fc9e3eccb5dd350264ba8fc066863e77d08dbc24608c8dc

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

module Ramaze

  # Shortcuts to some CGI methods

  module Helper::CGI
    # shortcut for CGI.escape

    def url_encode(*args)
      ::CGI.escape(*args.map{|arg| arg.to_s})
    end

    # shortcut for CGI.unescape

    def url_decode(*args)
      ::CGI.unescape(*args.map{|arg| arg.to_s})
    end

    # shortcut for CGI.escapeHTML

    def html_escape(string)
      ::CGI.escapeHTML(string.to_s)
    end

    # shortcut for CGI.unescapeHTML

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

    # safely escape all HTML and code
    def c(string)
      ::CGI.escapeHTML(string.to_s).gsub(/#/, '#')
    end

    # one-letter versions help in case like #{h foo.inspect}
    # ERb/ERuby/Rails compatible
    alias u url_encode
    alias h c
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.3.9 lib/ramaze/helper/cgi.rb
ramaze-0.3.9.1 lib/ramaze/helper/cgi.rb