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

https://github.com/emilindstrom/slugs

elixir package for generating slugs and extracting id:s
https://github.com/emilindstrom/slugs

elixir elixir-library slug slug-generator slugs

Last synced: about 1 year ago
JSON representation

elixir package for generating slugs and extracting id:s

Awesome Lists containing this project

README

          

# Slugs [![hex.pm version](https://img.shields.io/hexpm/v/slugs.svg)](https://hex.pm/packages/slugs) [![hex.pm downloads](https://img.shields.io/hexpm/dt/slugs.svg)](https://hex.pm/packages/slugs) [![Build Status](https://travis-ci.com/emilindstrom/slugs.svg?branch=master)](https://travis-ci.com/emilindstrom/slugs)

`generate` creates a slug from a combination of two values, preferably a combination of an id and a descriptive string.

`extract_id` grabs the id from the slug.

https://hex.pm/packages/slugs
## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `slugs` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:slugs, "~> 0.1.1"}
]
end
```

## Usage

```elixir
iex> Slug.generate(1337, "Lord Of The Rings")
"lord-of-the-rings-1337"

iex> Slug.extract_id("lord-of-the-rings-1337")
1337
```