Slugify-rs
A utility macro for flexible slug genereation that handles unicode.
The slugify! macro implements a flexible slug generator, allowing for stop words, custom separator and maximum length options. The macro provides both a simple interface with sane default parameters but also allows the parameters to be overriden when needed.
Features:
- Unicode strings support (phonetic conversion).
- Support for custom slug separator.
- Stop words filtering.
- Slug maximum length support.
- Add randomness to the generated slug to avoid unique constraint from acting
Usage
This crate is on crates.io and can be used by adding slugify to the dependencies in your project’s Cargo.toml
[]
= "0.0.3"
Examples Basic slug generation
assert_eq!;
// Using a custom separator
assert_eq!;
assert_eq!;
assert_eq!;
// Stop words filtering
assert_eq!;
// Maximum length
assert_eq!;
assert_eq!;
// Random values added to string through nanoid
// Default randomness string length is 5.
assert_eq!;
assert_eq!;
// Phonetic Conversion and accented text
assert_eq!;
assert_eq!;
assert_eq!;
// Passing multiple optional parameters.
// NOTE: the order of optional parameters matters: stop_words, separator and then max_length. All of them are optional, however when specifying more than one optional parameter, this order must be adhered.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Info
This slug was forked from the original slugify crate by @mattgathu