| Class | CGI |
| In: |
lib/more/facets/cgi.rb
|
| Parent: | Object |
| escapeHTML | -> | escape_html |
| unescapeHTML | -> | unescape_html |
| escapeElement | -> | escape_element |
| unescapeElement | -> | unescape_element |
Return an html "safe" version of the string, where every &, < and > are replaced with appropriate entities.
# File lib/more/facets/cgi.rb, line 33
33: def esc(str)
34: str.gsub(/&/,'&').gsub(/</,'<').gsub(/>/,'>')
35: end
Create an hidden input field through which an object can can be marshalled. This makes it very easy to pass from data between requests.
# File lib/more/facets/cgi.rb, line 21
21: def marshal_from_cgi(name)
22: if self.params.has_key?("__#{name}__")
23: return Marshal.load(CGI.unescape(self["__#{name}__"][0]))
24: end
25: end
Create an hidden input field through which an object can can be marshalled. This makes it very easy to pass from data betwenn requests.
# File lib/more/facets/cgi.rb, line 14
14: def marshal_to_cgi(name, iobj)
15: data = CGI.escape(Marshal.dump(iobj))
16: return %Q{<input type="hidden" name="__#{name}__" value="#{data}"/>\n}
17: end