Skip to content

henrik/slugalizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 

Repository files navigation

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.

About

Ruby slugalizer ("Föö Bár!" -> "foo-bar"). Uses ActiveSupport for platform-consistent normalization. Originally by Christoffer Sawicki.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages