An extension to Ruby's String
class that adds Jekyll-style #slugify
method.
- Add
jekyll_slugify
to dependencies:- Gemfile:
gem 'jekyll_slugify', '~> VERSION'
; or - gemspec file:
spec.add_dependency 'jekyll_slugify', '~> VERSION'
;
- Gemfile:
- Run
bundle install
to fetch the gem from RubyGems; - Require the gem on your code:
require 'jekyll_slugify'
- Apply the
#slugify
method on a string:
@foo = 'Hello Worlds!'
puts @foo.slugify
=> hello-worlds
Do note, however, that the slugify
method will not work on ideograms - an ideogram-only word will actually raise an error!
puts 'Ærøskøbing'.slugify # Works
=> aeroskobing
puts '指事字'.slugify # Raises a Runtime error
=> Empty `slug` generated for given String (RuntimeError)
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 🎉
Please, also read our Contributing Guidelines.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
See the Change Log for further history.
This project uses SemVer for versioning. For the versions available, see the tags on this repository.
This project is available under the MIT License.
The code on this project is adapted from Jekyll's Utils#slugify
method, available under the same MIT License.