Fermo Helpers v0.8.4 FermoHelpers.Slug View Source
Create slugs from id and text
Link to this section Summary
Functions
Returns a slug, combining id and title.
Link to this section Functions
Returns a slug, combining id and title.
Example
iex> FermoHelpers.Slug.from(123, "ciao")
"123-ciao"
Normalization
Punctuation is replaced by '-':
iex> FermoHelpers.Slug.from(123, "S&P")
"123-s-p"
The title is downcased:
iex> FermoHelpers.Slug.from(123, "AAAAA")
"123-aaaaa"
Non-Latin characters are transliterated:
iex> FermoHelpers.Slug.from(123, "andò")
"123-ando"
Separator characters are converted to '-':
iex> FermoHelpers.Slug.from(123, "R&R")
"123-r-r"
Leading '-' is removed:
iex> FermoHelpers.Slug.from(123, "-1")
"123-1"
Trailing '-' is removed:
iex> FermoHelpers.Slug.from(123, "1-")
"123-1"
The text part is capped at 51 characters:
iex> FermoHelpers.Slug.from(123, String.duplicate("a", 100))
"123-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"