- Source:
Methods
slugify(text, additionalMapopt, nullable, toLowerCaseopt, nullable) → {String}
Slugifies a text for use in a URL or id/class/attribute. Transforms accented characters to non-accented ones. Throws out everything except basic A-Z characters and numbers after replacements have taken place. Provide own replacements, supplementing or overriding the default replacement map to cover special cases (will take precedence over the default map).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text |
String | the text to slugify |
||
additionalMap |
String |
<optional> <nullable> |
null | optional character map to supplement/override the default map, having the form {'[search character]' : '[replacement]', ...} |
toLowerCase |
Boolean |
<optional> <nullable> |
true | set this to false, to keep character casing |
- Source:
Returns:
the slugified string
- Type
- String
Example
slugify('This is a cömplicated ßtring for URLs!')
=> 'this-is-a-coemplicated-sstring-for-urls'