web

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package web provides shared HTML template loading helpers used across services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseFuncMap

func BaseFuncMap() template.FuncMap

BaseFuncMap returns the set of template functions that don't depend on any service-specific state (store, world, etc.). Services augment this map with their own helpers before calling MustParseTemplates.

func MustSubFS

func MustSubFS(fsys fs.FS, dir string) fs.FS

MustSubFS returns a sub-filesystem rooted at dir, panicking on error.

Types

type TemplateMap

type TemplateMap map[string]*template.Template

TemplateMap holds one isolated *template.Template per page file so that each page's {{define "content"}} / {{define "title"}} etc. don't collide.

func MustParseTemplates

func MustParseTemplates(fsys fs.FS, funcs template.FuncMap, extra ...fs.FS) *TemplateMap

MustParseTemplates scans fsys/templates/, auto-detects partials (files that define no page-level blocks: title/sidebar/content/base), and builds one isolated *template.Template per page file. The caller provides funcs to merge into the FuncMap (typically from BaseFuncMap() plus service-specific helpers).

Optional extra FSes (e.g. chatux.FS) are treated as additional partials — all their templates/*.html files are parsed into every page template and __frags__, making their {{define}} blocks available everywhere.

The returned TemplateMap also contains a "__frags__" entry that holds all partials for HTMX partial responses.

Jump to

Keyboard shortcuts

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