ember-slugify

Library to slugify your strings within Ember.

Usage no npm install needed!

<script type="module">
  import emberSlugify from 'https://cdn.skypack.dev/ember-slugify';
</script>

README

ember-slugify

CI Ember Observer Score License: MIT

Library to slugify your strings within Ember.

This library uses:

Compatibility

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

Installation

ember install ember-slugify

Usage

In a js file

import slugify, { removeDiacritics } from 'ember-slugify'

let slug = slugify('Le Théâtre')
// le-theatre

slug = slugify('I ♥ New York')
// i-love-new-york

slug = slugify("Vive l'♥", { locale: 'fr' })
// vive-lamour

slug = slugify('bonjour monsieur', { replacement: '#' })
// bonjour#monsieur

slug = slugify('你好你怎么样 monsieur', { pinyin: true })
// ni-hao-ni-zen-me-yang-monsieur

slug = slugify('🇫🇷❤️🥖➕🍷', { emoji: true })
// flag-france-red-heart-baguette-bread-plus-wine-glass

let noDiacritics = removeDiacritics('Le Théâtre')
// Le Theatre

In a template

{{slugify 'Le Théâtre'}}

{{slugify '你好你怎么样 monsieur' (hash pinyin=true)}}

{{slugify '🇫🇷❤️🥖➕🍷' (hash emoji=true)}}

{{remove-diacritics 'Le Théâtre'}}

The separator option is not available on slugify helper.

Options

name description default value
replacement replace spaces with replacement character '-'
lower convert to lower case true
locale language code of the locale to use undefined
trim trim leading and trailing replacement chars true
pinyin replace chinese by latin character following the pinyin method false
emoji replace unicode emoji by it's description false

Contributing

See the Contributing guide for details.

Contributors

MrChocolatine
MrChocolatine
GreatWizard
GreatWizard
BlueCutOfficial
BlueCutOfficial
saintsebastian
saintsebastian
mathieupoteriepeopledoc
mathieupoteriepeopledoc
xcambar
xcambar

License

This project is licensed under the MIT License.