Documentation
¶
Overview ¶
templates/adapter.go
templates/engine.go
templates/funcs.go
templates/views.go
Index ¶
- func Funcs() template.FuncMap
- func Register(s Set)
- func Render(w http.ResponseWriter, r *http.Request, name string, data any)
- func RenderAuto(w http.ResponseWriter, r *http.Request, page, tableSnippet, targetID string, ...)
- func RenderAutoMap(w http.ResponseWriter, r *http.Request, page string, targets map[string]string, ...)
- func RenderSnippet(w http.ResponseWriter, name string, data any)
- func Reset()
- func UseEngine(e *Engine, l *zap.Logger)
- type Engine
- type Request
- type Set
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(s Set)
Register is typically called from a feature package’s init(). It records a template Set so the Engine can load it at Boot().
func RenderAuto ¶
func RenderAuto(w http.ResponseWriter, r *http.Request, page, tableSnippet, targetID string, data any)
Convenience for the common single-table swap case.
func RenderAutoMap ¶
func RenderAutoMap(w http.ResponseWriter, r *http.Request, page string, targets map[string]string, data any)
RenderAutoMap picks a snippet based on HX-Target; if HX-Target is "content", it renders the page's content-only block. Otherwise it renders the full page.
func RenderSnippet ¶
func RenderSnippet(w http.ResponseWriter, name string, data any)
RenderSnippet executes a partial by name (e.g., "groups_table").
Types ¶
type Engine ¶
Engine compiles and holds templates from all registered Sets. It supports a "shared" set (common layout) and per-page clones.
func (*Engine) Boot ¶
Boot compiles all registered template Sets into the Engine. It must be called before Render/RenderSnippet, typically at startup.
func (*Engine) Render ¶
Render executes a top-level template by name using this engine. Usually you’ll call the package-level Render helpers in adapter.go.
func (*Engine) RenderContent ¶
RenderContent executes the "content" block associated with the given entry template.
type Set ¶
type Set struct {
// Name is for logging / debugging only (e.g., "shared", "admin_resources").
Name string
// FS is the embedded filesystem from the feature package.
FS fs.FS
// Patterns are the glob patterns to load from FS (e.g., []string{"templates/*.gohtml"}).
Patterns []string
}
Set describes one module's template set.