ElixirExtensions.Core.StringExt (elixir_extensions v0.1.2)
Functions to string truncate
Summary
Functions
Returns string
as a slug or nil
if it failed.
Functions
Link to this function
slugify(string, options \\ [])
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 tofalse
if you wish to retain capitalization. Defaults totrue
.: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> slugify("Hello, World!")
"hello-world"
iex> slugify("Madam, I'm Adam", separator: "")
"madamimadam"
iex> slugify("StUdLy CaPs", lowercase: false)
"StUdLy-CaPs"
iex> slugify("Call me maybe", truncate: 10)
"call-me"
iex> slugify("你好,世界", ignore: ["你", "好"])
"你好-shi-jie"
Link to this function
truncate(text, options \\ [])
Examples
iex> truncate("hello world", length: 5)
"he..."