Slugify v1.3.1 Slug View Source
Transform strings from any language into slugs.
It works by transliterating Unicode characters into alphanumeric strings (e.g.
字 into zi). All punctuation is stripped and whitespace between words are
replaced by hyphens.
Link to this section Summary
Functions
Returns string as a slug or nil if it failed.
Link to this section Functions
Specs
Returns string as a slug or nil if it failed.
Options
- :separator- Replace whitespaces with this string. Leading, trailing or repeated whitespaces are trimmed. Defaults to- -.
- :lowercase- Set to- falseif you wish to retain capitalization. Defaults to- true.
- :truncate- Truncates slug at this character length, shortened to the nearest word.
- :ignore- Pass in a string (or list of strings) of characters to ignore.
Examples
iex> Slug.slugify("Hello, World!")
"hello-world"
iex> Slug.slugify("Madam, I'm Adam", separator: "")
"madamimadam"
iex> Slug.slugify("StUdLy CaPs", lowercase: false)
"StUdLy-CaPs"
iex> Slug.slugify("Call me maybe", truncate: 10)
"call-me"
iex> Slug.slugify("你好,世界", ignore: ["你", "好"])
"你好-shi-jie"