Skip to content

Instantly share code, notes, and snippets.

@joaofraga
Created August 29, 2013 19:16
Show Gist options
  • Save joaofraga/6382232 to your computer and use it in GitHub Desktop.
Save joaofraga/6382232 to your computer and use it in GitHub Desktop.
Remove all html entities and sanitize a string.
# 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