Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Modules: String
Alex Bruno Cáceres edited this page Mar 2, 2023
·
1 revision
Useful methods to deal with strings.
Transforms a string into a slug string, eligible for web URLs.
Normalizes the string by replacing spaces with dashes and special characters with simpler ASCII equivalents.
It is possible to transform the string into full lowercase or full uppercase by setting the lower or upper options.
import{slugify}from'@jsweb/utils/modules/string'consttest='Hello World'slugify(test)// Hello-Worldslugify(test,{lower: true})// hello-worldslugify(test,{upper: true})// HELLO-WORLDRenders a tagged template string with the given data and returns the result string.
Useful to render templates with dynamic data.
import{template}from'@jsweb/utils/modules/string'template('Hello ${name}!',{name: 'World'})// Hello World!template('Lorem ${ipsum} dolor ${sit} amet',{ipsum: 'foo',sit: 'bar',})// Lorem foo dolor bar amet