Railsify!

Permalizer

Permalize


Following Rails conventions, such as camelize, pluralize, titleize, etc, I've created permalize. Basically, it takes any string and makes it into a permanent link. It doesn't add ID's to the front of the string, nor does it do any database searching for existing string. It just simply permalizes any given string with proper handling of unicode characters.

Example


There are two ways you can use this plugin. 

1)

string = "Here is the new string"
new_string = string.permalize

results:

string 			= "Here is the new string"
new_string 	= "here-is-the-new-string"

2)

string = "Here is the new string"
string.permlize!

results:

string = "here-is-the-new-string"

Read the tests to see how extensive this really is, in only 3 parsing lines of code. :)

Copyright (c) 2007 Robert R Evans, released under the MIT license

Last updated: September 08, 2007 00:30