Skip to content

Document Creator 0.7.0: Template addresses that stay put when renamed

Document Creator 0.7.0 fixes how templates get their slug, the short name used to look a template up. Renaming a template no longer changes it, and two templates with the same name no longer share one.

Renaming no longer moves a template

Every save that changed a template’s name, without an explicit slug, worked out a new slug from the new name, and the old one was not kept anywhere. Anything that looked the template up by its slug lost it. The module now uses PhoenixKit’s shared slug handling: an explicit slug wins, a slug cleared on purpose is generated again from the name, and otherwise the stored slug stays as it is.

Unique slugs

Nothing checked whether a slug was already taken, so two templates with the same name ended up with the same slug and lookups by slug broke. New slugs now get -2, -3 and so on until they are free.

A slug generated from a very long name could also exceed the 255-character column and make the save fail. Generated slugs, including the number added for uniqueness, are now trimmed to fit.

Form styling

The module’s form fields, selects and inputs now use the current daisyUI 5 field classes, so they match the rest of the PhoenixKit admin.

Upgrading

The module now needs PhoenixKit 2.4 or later, because templates use core’s slug function, which earlier 2.x releases do not have. On an older core every template save would fail. No migration. Existing slugs stay as they are; only new or explicitly changed slugs follow the new rules.

Full release notes: Document Creator 0.7.0

0.7.0 · 14 August 2026

Changed

  • ⚠️ Requires phoenix_kit ~> 2.4. Template.changeset/2 now calls PhoenixKit.Utils.Slug.put_slug/3, which core did not ship until 2.4.0. The pin was raised from ~> 2.0 because that range admits cores where the function does not exist — and the failure would land in the consumer’s app as an UndefinedFunctionError on every save touching :name, never in this repo’s own run, since the workspace always resolves the newest core. Still two-segment, so every later 2.x satisfies it.

    core_pin_conformance_test.exs moved with it, and now guards both directions: too narrow (a three-segment pin collapsing to one minor) and too wide (a core lacking the function this module calls).

Fixed

  • Renaming a template moved its URL. The local maybe_generate_slug/1 keyed on get_change(:slug) being nil, which is true both when the caller left the slug alone and when the record hasn’t got one — so any save carrying no slug of its own re-derived it from the name, and nothing recorded the old one. Core’s put_slug/3 distinguishes the two: an explicit slug wins, an explicitly blanked one regenerates, and no slug at all defers to the stored record (#39).

  • Two templates with the same name silently shared a slug. Nothing ever probed for collisions, which broke get-by-slug lookups. Slugs are now suffixed -2, -3 … until free, excluding the row itself on update.

  • A generated slug could overflow varchar(255). validate_length(:slug) sat before generation, so it only ever saw explicitly-cast slugs; it now runs after, and put_slug/3 is given max_length: 255 so the suffix is trimmed into the cap rather than overflowing it (Postgres raises rather than truncating).

  • Two :requires_unreleased_core moduletags excluded nothing. This repo’s test_helper.exs stopped excluding that tag at core 2.0, so the slug tests were running against a Hex-resolved core all along rather than being masked as the PR assumed. Removed now that the pin guarantees the function is there.


Document Creator 0.7.0. Install or update: {:phoenix_kit_document_creator, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.