Package template is a thin wrapper around the standard html/template and text/template packages that implements a convenient registry to load and cache templates on the fly concurrently.

It was created to assist the JSVM plugin HTML rendering, but could be used in other Go code.

Example:

 registry := template.NewRegistry()

html1, err := registry.LoadFiles(
// the files set wil be parsed only once and then cached
"layout.html",
"content.html",
).Render(map[string]any{"name": "John"})

html2, err := registry.LoadFiles(
// reuse the already parsed and cached files set
"layout.html",
"content.html",
).Render(map[string]any{"name": "Jane"})

Index

Interfaces

Generated using TypeDoc