Sha256: da0d7fd75b4e422540e1fb3cd3b90c2edb22df8dbd3b139a17a22370c6ec3e22
Contents?: true
Size: 782 Bytes
Versions: 3
Compression:
Stored size: 782 Bytes
Contents
# encoding: utf-8 class String if !respond_to?(:sluglize) # accepts a string and return slug string #if you're changing this regex, make sure to change the one in /javascripts/slug_management.js too # utf-8 special chars are fixed for new ruby 1.9.2 def sluglize new_slug = self unless new_slug.blank? new_slug = new_slug.to_s.downcase.gsub(/\s/, '-').gsub(/[\!\*'"″′‟‛„‚”“”˝\(\)\;\:\.\@\&\=\+\$\,\/?\%\#\[\]]/, '') new_slug = new_slug.gsub(/_$/,'-') # replace underscores with hyphen while new_slug.include?("--") new_slug = new_slug.gsub('--','-') # remove consective hyphen end new_slug = new_slug.gsub(/-$/,'') # remove trailing hyphen end new_slug end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gluttonberg-core-3.0.2 | lib/gluttonberg/extensions/string.rb |
gluttonberg-core-3.0.1 | lib/gluttonberg/extensions/string.rb |
gluttonberg-core-3.0.0 | lib/gluttonberg/extensions/string.rb |