Add htmx v4 support#881
Open
dienhoa wants to merge 24 commits into
Open
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
name: Pull Request
about: Propose changes to the codebase
title: '[PR] Add opt-in htmx v4 support'
labels: ''
assignees: ''
Proposed Changes
This PR adds htmx v4 support to FastHTML while keeping htmx v2 as the default behavior.
Apps can enable htmx v4 with:
The main changes are:
htmx4=Truesupport tofast_app()andFastHTML.4.x.xwhenhtmx4=True.metaCharacter="-"so v4-style attributes and events work with Python keyword syntax.HtmxHeaders, includingHX-SourceandHX-Request-Type.valuesand lowercaseheaders.htmx4=True, including WebSocket and SSE support.HxPartialfor htmx v4 partial updates.sse_message(..., htmx4=True)so default SSE messages omit theevent:line, matching htmx v4 behavior.HtmxOn,PicoBusy, and session-id handling for htmx v4 event names and event detail structure.htmx v2 remains the default. Existing apps using
fast_app()orFastHTML()withouthtmx4=Trueshould continue using the existing htmx v2 behavior.Existing FastHTML projects can use the compatibility checker during migration to htmx v4. It scans Python source files for htmx attributes and event handlers that are specific to htmx v2 or htmx v4, then reports cases where they do not match the target version.
The migration documentation and examples are included in the
htmxv4_migration/folder.Types of changes
What types of changes does your code introduce? Put an
xin all the boxes that apply:Checklist
Go over all the following points, and put an
xin all the boxes that apply: