Created
March 30, 2012 11:28
-
-
Save mahemoff/2250926 to your computer and use it in GitHub Desktop.
Escape HTML Entities using Ruby 1.9.2 gsub hash syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def escape(s) | |
s.gsub(/[&<>"]/, '&' => '&', '>' => '>', '<' => '<', '"' => '"') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment