Slugalizer is a one-method Ruby library that can slugalize (or slugify) strings, like this:
Slugalizer.slugalize("Åh, räksmörgåsar!") # => "ah-raksmorgasar"
Defaults to the "-" word separator but can also use "+" or "_":
Slugalizer.slugalize("Åh, räksmörgåsar!", "+") # => "ah+raksmorgasar" Slugalizer.slugalize("Åh, räksmörgåsar!", "_") # => "ah_raksmorgasar"
ActiveSupport::Multibyte (part of Ruby on Rails since 1.2) for platform-consistent normalization/decomposition, since
iconv from the Ruby standard library is inconsistent between platforms.
This library has been incorporated into Ruby on Rails (as
String#parameterize) since 2008-09-23 (Rails 2.2). The library is still of use outside Rails, or with earlier Rails versions. It also has more extensive tests than the code in Rails, and some additional error handling (limited set of word separators, handling non-string input).
Originally by Christoffer Sawicki.
Modified by Henrik Nyh.
Released into the public domain.