Skip to content

Update startapp for htmx 4 - #50

Merged
czue merged 2 commits into
mainfrom
htmx-upgrade
Nov 10, 2026
Merged

czue merged 2 commits into
mainfrom
htmx-upgrade

Conversation

@czue

@czue czue commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Updates the startapp templates for htmx 4, to go with the Pegasus htmx 4 upgrade.

Changes

Templates (7a26ea2)

  • htmx 4 no longer inherits attributes implicitly, so the #page-content wrapper in the home, list, detail and form templates now uses hx-target:inherited="#page-content". Without it, links and the form inside the wrapper would target themselves.
  • htmx 4 sends HX-Target as tag#id instead of the bare id, so the list view now checks request.htmx.target == "div#page-content". Previously the comparison always failed on htmx 4, and breadcrumb navigation to the list page rendered only the table partial.

Pagination (web/components/paginator_htmx.html) is updated on the Pegasus side. The create/edit form, redirect + hx-push-url, and the plain-POST delete form need no changes.

htmx version check (86eed0f)

  • The generated templates are htmx 4 only. startapp now reads htmx.org from the project's package.json, and if its major version is below 4 it stops with a message: upgrade Pegasus, install pegasus-cli<0.17, or re-run with --force.
  • It's deliberately forgiving: a missing or unparseable package.json, no htmx dependency, or an unreadable version spec all let the command run.

Notes

  • The error message assumes this ships as 0.17.
  • Pegasus currently depends on pegasus-cli>=0.15; the htmx 4 Pegasus release should bump that to this version.

Testing

  • pytest: 133 passed, including new tests in tests/test_startapp.py.
  • Ran startapp in a scratch dir against an htmx 2 package.json: it errors, and with --force it generates the app with the new attributes and view check.
  • Generated a widgets app in a Pegasus project on htmx 4.0.1 and clicked through it in the browser; it works. (For comparison, the same app generated by the released 0.16 CLI nests every swap inside the clicked element on htmx 4.)

🤖 Generated with Claude Code

czue and others added 2 commits November 10, 2026 14:11
htmx 4 no longer inherits attributes implicitly, so the page-content
wrapper needs hx-target:inherited for its links and forms to target it.
HX-Target is now sent as tag#id, so the list view matches div#page-content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated templates now require htmx 4. Stop with a clear message if the
project's package.json has an older htmx, with --force to skip the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@czue
czue merged commit 3bd1a4d into main Nov 10, 2026
10 checks passed
@czue
czue deleted the htmx-upgrade branch November 10, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant