Skip to content

Releases: donseba/go-partial

v0.14.0

Choose a tag to compare

@donseba donseba released this 06 Oct 06:14

Full Changelog: v0.13.0...v0.14.0

v0.13.0

Choose a tag to compare

@donseba donseba released this 05 Oct 18:38
7662300

What's Changed

  • Keep templates from different file systems apart in the cache by @donseba in #23

Full Changelog: v0.12.0...v0.13.0

v0.12.0

Choose a tag to compare

@donseba donseba released this 04 Oct 20:16
0d5775e

What's Changed

  • Add HTMX 4 connector with protocol-specific response serialization by @donseba in #22

Full Changelog: v0.11.0...v0.12.0

v0.11.0

Choose a tag to compare

@donseba donseba released this 03 Oct 13:09
2dad7ad

What's Changed

  • Remove unreachable checks and pin the lint workflow by @donseba in #20
  • Flush SSE responses through middleware wrappers by @donseba in #19
  • Update README and link component logo to documentation by @donseba in #21

Full Changelog: v0.10.0...v0.11.0

v0.10.0

Choose a tag to compare

@donseba donseba released this 16 Jul 08:02

Full Changelog: v0.9.0...v0.10.0

v0.9.0

Choose a tag to compare

@donseba donseba released this 01 Jul 20:40
c54767b

Headline changes

  • Partial is now reusable tree/configuration data. Rendering is done through
    package functions: partial.Render, partial.RenderWithRequest, and
    partial.Write.
  • Service and Layout have been removed. A root partial now acts as the
    page shell/blueprint and can be cloned per request.
  • Render extension points are now called render stages:
    partial.RenderStage, partial.RenderStageHooks, and Partial.Use.
  • Request-scoped render state has been moved out of Partial and into
    RenderContext, fixing data bleed risks during concurrent renders.
  • New experimental and extension packages provide focused helpers for HTMX/SSR
    applications: flash messages, interactions, selection, actions, target
    resolution, SSE, slots, page flow, localization, CSRF, metrics, OpenTelemetry,
    debug rendering, error rendering, and logging.
  • Documentation and showcase have been rebuilt around the new root blueprint
    model.

Breaking changes

Service and Layout were removed

The old partial.NewService(&partial.Config{...}), Service.NewLayout,
Layout.Set, Layout.Wrap, Layout.RenderWithRequest, and
Layout.WriteWithRequest APIs are gone.

Use a configured root partial instead:

root := partial.NewID("shell", "templates/shell.gohtml").
    SetFileSystem(os.DirFS("web")).
    SetConnector(connector.NewHTMX(nil)).
    Use(exterrors.Stage())

func handler(w http.ResponseWriter, r *http.Request) {
    content := partial.NewID("content", "templates/home.gohtml").
        SetDot(HomePage{})

    page := root.Clone().SetContent(content)

    if err := partial.Write(r.Context(), w, r, page); err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }
}

Partial render methods were removed

The old methods:

p.Render(ctx)
p.RenderWithRequest(ctx, r)
p.WriteWithRequest(ctx, w, r)

are replaced by:

partial.Render(ctx, p)
partial.RenderWithRequest(ctx, r, p)
partial.Write(ctx, w, r, p)

partial.Write owns HTTP response behavior: configured headers, connector
response headers, stage response metadata, error fragments, and out-of-band
regions.

Renderer terminology was replaced by render stages

The old renderer hook vocabulary has been replaced with stages:

root.Use(partial.RenderStageHooks{
    PrepareFunc: func(ctx *partial.RenderContext) (*partial.RenderContext, error) {
        return ctx, nil
    },
})

Extension packages now expose Stage(...) constructors, for example
metrics.Stage(...), flash.Stage(...), exterrors.Stage(...), and
interactions.Stage(...).

Built-in helper surface is smaller

Core only protects and injects helpers that it needs for rendering:
ctx, request, url, runtime, partial, content, OOB helpers, and
connector state helpers.

Generic helpers such as dict, string helpers, date helpers, collection
helpers, and counters now live in:

github.com/donseba/go-partial/exp/templatehelpers

Register them explicitly:

root.SetFunc(templatehelpers.FuncMap())

Interaction helpers moved to exp/interactions

Core no longer auto-registers async, poll, reveal, on, stream,
prefetch, or refresh.

Use:

root.SetFunc(interactions.FuncMap())
root.Use(interactions.Stage())

The helpers support both endpoint-string usage and typed
interactions.Interaction values registered with SetContract("interaction", ...).

Old JavaScript assets and legacy examples were removed

The old js/ package and older standalone examples were removed. The showcase
and docs apps are now the canonical examples.

Connector cleanup

Unused legacy connector shims were removed. The maintained connector focus is
now HTMX, Turbo, Unpoly, and the generic partial connector.

New core capabilities

Request-safe render context

RenderContext carries request-scoped data, functions, events, response
metadata, selected target information, and stage values. Reusable partial trees
do not store request data during rendering.

This is covered by new concurrency tests for:

  • partial renders
  • cloned root/shell renders
  • cached template renders
  • stage values
  • target rendering
  • OOB rendering
  • connector reads
  • request context fallback

Root blueprint rendering

A configured root partial can be reused as a blueprint:

root := partial.New("templates/shell.gohtml").Use(allStages...)

page := root.Clone().
    SetContent(partial.NewID("content", "templates/blog.gohtml"))

Clone copies the partial tree configuration so request-specific content,
dot data, and response state can be attached without mutating the shared
blueprint.

Connector response builder

Connector response behavior is now configurable through Partial.Response()
and SetResponse, including retargeting, reswapping, triggers, redirects,
refreshes, and URL updates. partial.Write applies those headers.

Diagnostic events

The new event system emits render lifecycle, template, content, target,
contract, OOB, and write diagnostics.

Useful entry points:

events := partial.NewAsyncEvents(partial.EventsConfig{Buffer: 256}, sink)
root.SetEvents(events)
ctx := partial.WithEventSink(r.Context(), requestSink)

New packages

exp/flash

Experimental flash message helpers for SSR and HTMX responses.

Features:

  • default embedded message and target templates
  • overrideable message and target partials
  • levels: success, info, warn, error, and custom levels
  • request-scoped stores
  • OOB-friendly flashTarget and flash helpers
  • concurrency coverage

exp/interactions

Typed and endpoint-based helpers for HTMX-style interactions:

  • async/deferred regions
  • reveal
  • poll
  • stream
  • prefetch
  • refresh
  • event-triggered interactions
  • go-doc metadata for helper signatures

exp/templatehelpers

Optional generic template helpers for strings, URLs, safe HTML, time,
collections, numbers, and dictionaries.

exp/target

Dynamic target resolution for requests where the target ID maps to data-backed
partials, such as row updates.

exp/selection and exp/actions

Selection and action helpers were split into focused packages instead of being
part of core rendering.

exp/slots

Named slots for composing child partials through template helpers.

exp/sse

Server-Sent Events writer helpers that can render partials through the same
stage chain as normal responses.

exp/localization and exp/csrf

Request-context based localization and CSRF helper packages.

exp/metrics and exp/otel

Passive render metrics and OpenTelemetry event sinks.

ext/errors, ext/debug, ext/logger

Optional non-experimental extensions for error output, debug rendering, and
structured logging.

Documentation and showcase

The docs and showcase have been rebuilt around the current API:

  • root blueprint setup
  • request context guidance
  • render stages
  • error boundaries
  • diagnostic events
  • observability
  • template helper providers
  • flash messages
  • interactions/deferred rendering
  • target resolution
  • selection/action helpers
  • SSE
  • page flow
  • localization
  • connectors

The old small examples were removed in favor of the new showcase and docs apps.

go-doc support

The repository now includes .go-doc/config.json and typed contract metadata
for template helper discovery.

Important APIs:

SetModel(values...)
SetContract(annotation, values...)
SetDot(value)
SetFunc(funcMaps...)

NamedContract lets values choose a stable contract name.

Tooling and CI

  • The module now targets the Go version declared in go.mod.
  • The golangci-lint workflow now uses Node 24-compatible actions:
    actions/checkout@v5, actions/setup-go@v6, and
    golangci/golangci-lint-action@v9.
  • Tailwind-based CSS builds were added for docs and showcase.
  • New tests cover rendering, events, stages, template caching, connectors,
    experimental packages, and concurrency-sensitive paths.

Migration checklist from v0.8.0

  1. Replace NewService and Layout usage with a reusable root partial.
  2. Replace p.Render, p.RenderWithRequest, and p.WriteWithRequest with
    partial.Render, partial.RenderWithRequest, and partial.Write.
  3. Replace renderer hook terminology with RenderStage and RenderStageHooks.
  4. Move generic helpers to exp/templatehelpers and register them explicitly.
  5. Move async/poll/reveal/on/stream/prefetch/refresh helpers to
    exp/interactions.
  6. Add exterrors.Stage() from github.com/donseba/go-partial/ext/errors
    where you want rendered failure responses from partial.Write.
  7. Clone reusable root partials before attaching request-specific content or
    dot data.
  8. Pass r.Context() or a derived request context into rendering and writing.
  9. Use SetEvents or WithEventSink for diagnostics instead of render-time
    state on Partial.

Release intent

v0.9.0 intentionally breaks parts of v0.8.0 so the project can enter the
v1.0 feedback period with a cleaner core API. The core is now smaller and more
explicit, while SSR/HTMX-oriented behavior lives in focused exp and ext
packages that can mature with real application feedback.

v0.8.0

Choose a tag to compare

@donseba donseba released this 04 Dec 22:11
8d46012

What's Changed

  • refactor to work with connectors as mentioned in #8 and #7 and #3 by @donseba in #16

Full Changelog: v0.7.0...v0.8.0

v0.7.0

Choose a tag to compare

@donseba donseba released this 26 Nov 07:58
4ef3ae4

What's Changed

Full Changelog: v0.6.0...v0.7.0

v0.6.0

Choose a tag to compare

@donseba donseba released this 25 Nov 14:17
568e4d5

What's Changed

Full Changelog: v0.5.0...v0.6.0

afbeelding
afbeelding

v0.5.0

Choose a tag to compare

@donseba donseba released this 22 Nov 17:09
485341f

What's Changed

  • add examples and some qol changes throughout by @donseba in #13

Full Changelog: v0.4.0...v0.5.0

afbeelding