Created
August 29, 2013 19:16
-
-
Save joaofraga/6382232 to your computer and use it in GitHub Desktop.
Remove all html entities and sanitize a string.
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
# Add this to Gemfile, then run 'bundle install' | |
gem "htmlentities" | |
# Add this to your helper | |
def truncate_and_sanitize(text, args={}) | |
truncate sanitize(HTMLEntities.new.decode(text), tags: []), args | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment