module Marten::Core::Sluggable
Overview
The Sluggable module provides functionality for generating URL-friendly slugs from strings.
Direct including types
Defined in:
marten/core/sluggable.crInstance Method Summary
-
#generate_slug(value, max_size)
Generates a slug from the given value, ensuring the resulting slug does not exceed the specified max_size.
Instance Method Detail
def generate_slug(value, max_size)
#
Generates a slug from the given value, ensuring the resulting slug does not exceed the specified max_size.
The slug is created by:
- Removing non-alphanumeric characters (except for Unicode letters, numbers, symbols, whitespace, and hyphens).
- Converting the string to lowercase.
- Replacing sequences of whitespace and hyphens with a single hyphen.
- Stripping trailing hyphens and underscores from the slug.
- Truncating the slug to the specified max_size.