Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
class String # Wrapper for HTMLEntities gem which falls back on CGI.unescapeHTML def unescape begin require 'htmlentities' @@coder ||= HTMLEntities.new @@coder.decode(self) rescue LoadError logger.warn "HTMLEntities gem not found. Using (substantially inferior) CGI.unescapeHTML" CGI.unescapeHTML(self) end end # Wrapper for HTMLEntities gem which falls back on CGI.escapeHTML def escape begin require 'htmlentities' @@coder ||= HTMLEntities.new @@coder.encode(self, :basic, :decimal) rescue logger.warn "HTMLEntities gem not found. Using (substantially inferior) CGI.escapeHTML" CGI.escapeHTML(self) end end end
From the Design Piracy series on my blog: