6.0.0 • Published 5 months ago

ember-slugify v6.0.0

Weekly downloads
649
License
MIT
Repository
github
Last release
5 months ago

ember-slugify

CI Ember Observer Score License: MIT

Library to slugify your strings within Ember.

This library uses:

Compatibility

  • Ember.js v4.8 or above
  • Embroider or ember-auto-import v2

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

namedescriptiondefault value
replacementreplace spaces with replacement character'-'
lowerconvert to lower casetrue
localelanguage code of the locale to useundefined
trimtrim leading and trailing replacement charstrue
pinyinreplace chinese by latin character following the pinyin methodfalse
emojireplace unicode emoji by it's descriptionfalse

Contributing

See the Contributing guide for details.

Contributors

License

This project is licensed under the MIT License.