htmx-dynamic

command
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 7 Imported by: 0

README

HTMX + dynamic templates

A minimal server-rendered page that returns HTML partials in response to HTMX-triggered requests. Demonstrates:

  • Loading HTML templates from ./templates via server.WithTemplateDir.
  • Serving static assets (the HTMX <script> tag) from ./static.
  • Returning a partial (not a full page) for HTMX to swap in.

The pattern is for teams that want HTMX-style interactivity without a JavaScript bundler — server-rendered HTML, server-owned state, plus the small htmx.js script loaded once.

Run

go run ./examples/htmx-dynamic &
open http://localhost:8080

Click the button; HTMX issues a GET /load-content; the server returns a template fragment; HTMX swaps it into the DOM. No SPA, no bundler.

Files

  • main.go — server, two routes (/ full page, /load-content fragment).
  • templates/ — Go html/template source for both shapes.
  • static/htmx.js (vendored so the example runs offline).

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL