Skip to content

htmx 4: new core attributes and hx-partial element #22

Description

@maragubot

Part of #18. Depends on the Modifier type from the modifiers sub-issue. Core attributes only; extension attributes are out of scope by decision. Reference: https://four.htmx.org/reference/attributes

New attribute helpers

Helper Attribute Notes
Action(url) hx-action URL for the request, mirroring native action.
Method(v) hx-method get, post, put, patch, delete, query.
Query(url) hx-query Issues an HTTP QUERY request.
Config(v) hx-config HCON or JSON string. Replaces hx-request.
Status(code, v) hx-status:<code> Key-form attribute like On. code is a string so 50x/5xx wildcards work.
MorphSkip() hx-morph-skip Bare attribute.
MorphSkipChildren() hx-morph-skip-children Bare attribute.

All take ...Modifier. Values stay plain strings; typed/map forms for JSON-valued attributes are a possible follow-up, not part of this.

New element: hx-partial

<hx-partial hx-target="..." hx-swap="..."> is a response-side element for multi-target updates. https://four.htmx.org/reference/tags/hx-partial

func Partial(children ...g.Node) g.Node  // g.El("hx-partial", children...)

Targets and swaps are passed as ordinary Target/Swap attribute children. The <template hx type="partial"> variant is not needed since gomponents does not strip unknown tags.

Acceptance criteria

  • Each helper above exists with a verbatim doc comment linking to the reference page, a test, and a godoc Example.
  • Partial renders <hx-partial hx-target="#x" hx-swap="outerHTML">...</hx-partial>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions