Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diegok/slugit-jquery
Just another jquery slugify plugin
https://github.com/diegok/slugit-jquery
Last synced: about 1 month ago
JSON representation
Just another jquery slugify plugin
- Host: GitHub
- URL: https://github.com/diegok/slugit-jquery
- Owner: diegok
- Created: 2010-10-01T15:29:01.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2021-01-29T15:08:26.000Z (almost 4 years ago)
- Last Synced: 2024-11-10T23:53:52.413Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 49
- Watchers: 10
- Forks: 24
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
===================================================
slugIt - just another jQuery slugs generator plugin
===================================================I've created this one because I wanted a jQuery slug plugin capable of convert
european utf8 chars plus some symbols and easily extensible for custom extra mappings.
None of the ones listed on http://plugins.jquery.com/plugin-tags/slug does what I needed.I got the idea of this plugin after using the excelent perl module Text::Unidecode
(http://search.cpan.org/dist/Text-Unidecode/) for this same task server side.I've taken some chars tables from Django admin urlify.js
(http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/media/js/urlify.js)
as this one was the most similar aproach to what I was looking to implement over jQuery.Requirements
============Requires JQuery (It should work with all version)::
Usage
=====Load this plugin like any other::
Then, you select the source field to be converted::
$(function(){
$('#slugme').slugIt();
});
"I love my umbrella'" will be converted to "i-love-my-umbrella"
Options
-------While the slugIt() method has some defaults that make the previous example to work, you'll be probably
inerested in customize for your convenience. These are the available options and their defaults::{
events: 'keypress keyup', // Any sensible jquery event (http://api.jquery.com/category/events/)
output: '#slug', // A selector or function to send the generated slug
separator: '-', // A separator which will be use to separate wordsmap: false, // A hash with extra replacemets.
// You can overwrite default replacements just passing the
// ones you like to replace.before: false // Callback that will be fired before processing slug (you can modify the input)
after : false // Callback that will be fired after processing slug (You can modify the slug)
}Examples
--------You can add some extra mappings::
$(function(){
$('#slugme').slugIt({ map: { '☂': 'umbrella' } });
});
...So, "I ♥ my ☂'" will be converted to "i-love-my-umbrella"
Or customize word separator::
$(function(){
$('#slugme').slugIt({ separator: '_' });
});
Now, "I love my umbrella'" will be converted to "i_love_my_umbrella"
Working examples can be found at http://github.com/diegok/slugit-jquery/tree/master/examples/
Licensing
---------
BSD License can be found at http://www.opensource.org/licenses/bsd-license.php