Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dazzlingfugu/ember-slugify

Library to slugify your strings within Ember.
https://github.com/dazzlingfugu/ember-slugify

ember ember-addon hacktoberfest slug slugify

Last synced: 4 months ago
JSON representation

Library to slugify your strings within Ember.

Awesome Lists containing this project

README

        

# ember-slugify

[![CI](https://github.com/DazzlingFugu/ember-slugify/actions/workflows/ci.yml/badge.svg)](https://github.com/DazzlingFugu/ember-slugify/actions/workflows/ci.yml) [![Ember Observer Score](https://emberobserver.com/badges/ember-slugify.svg)](https://emberobserver.com/addons/ember-slugify) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Library to slugify your strings within Ember.

This library uses:

- [slugify](https://github.com/simov/slugify)
- [simple-pinyin](https://github.com/xuqingkuang/simple-pinyin)
- [emoji.json](https://github.com/amio/emoji.json)

## Compatibility

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

## Installation

```
ember install ember-slugify
```

## Usage

### In a `js` file

```js
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

```hbs
{{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](CONTRIBUTING.md) guide for details.

## Contributors



MrChocolatine


MrChocolatine




GreatWizard


GreatWizard




saintsebastian


saintsebastian




BlueCutOfficial


BlueCutOfficial




mathieupoteriepeopledoc


mathieupoteriepeopledoc




romgere


romgere



ndekeister-us


ndekeister-us




xcambar


xcambar

## License

This project is licensed under the [MIT License](LICENSE.md).