jQuery FriendlyId Rails
This library was inspired by norman/friendly_id, originally developed for Rails ActiveRecord.
Usage
You can simple get the slug of string:
$.friendly_id('Café is good');
// It will return "cafe-is-good".
If you would like, you can change the separator:
$.friendly_id('Café is good', '_');
// It will return "cafe_is_good".
And finally, you can dynamically generate the slug:
$('.input').on('keyup', function() {
var slug = $.friendly_id($(this).val());
return $('.output').val(slug);
});
Thanks
- CakePHP: for transliteration map.
- Rails: for the idea of transliterate and parameterize methods.
- Vinicius Cainelli: for the original library.