View Source AshSlug.Changes (ash_slug v0.2.1)

Change functions for the AshSlug extension.

Summary

Functions

Slugify a string attribute on a changeset.

Functions

slugify(attribute, opts \\ [])

Slugify a string attribute on a changeset.

Options

  • :attribute (atom/0) - Required. The attribute to slugify.

  • :into (atom/0) - The attribute to store the slug in. Unless specified, the slug will be stored in the same attribute.

  • :lowercase? (boolean/0) - Whether to lowercase the slug. The default value is true.

  • :separator (String.t/0) - The separator to use between words in the slug. The default value is "-".

  • :truncate (integer/0) - Truncates the slug at this character length, shortened to the nearest word.

  • :ignore (one or a list of String.t/0) - A string or list of strings of characters to ignore when slugifying. The default value is [].

Examples

change slugify(:text)
change slugify(:text, into: :text_slug, lowercase?: false, ignore: [".", "!"])