Ruby slugalizer ("Föö Bár!" -> "foo-bar"). Uses ActiveSupport for platform-consistent normalization. Originally by Christoffer Sawicki.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


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"

Uses 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 ActiveSupport::Inflector#parameterize and 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.