Skip to content

An Ash extension to seamlessly slugify string attributes on a resource

License

Notifications You must be signed in to change notification settings

ash-project/ash_slug

Repository files navigation

Logo Logo

Elixir CI License: MIT Hex version badge Hexdocs badge

AshSlug

AshSlug is an Ash extension to slugify string attributes on a resource.

The extension is a thin wrapper around the Slugify library, and supports the same options.

Example usage

defmodule MyDomain.Resource do
  @moduledoc false

  use Ash.Resource,
    domain: MyDomain,
    data_layer: Ash.DataLayer.Ets,
    extensions: [AshSlug]

  ets do
    private?(true)
  end

  attributes do
    uuid_primary_key(:id)
    attribute(:text, :string, public?: true)
    attribute(:text_slug, :string)
  end

  actions do
    create :create do
      accept([:text])
      change slugify(:text, into: :text_slug)
    end
  end
end

Reference

About

An Ash extension to seamlessly slugify string attributes on a resource

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages