Back to Pocketbase

Namespace template

static/jsvm/modules/template.html

latest1.0 KB
Original Source

Namespace template

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"})Copy

Index

Interfaces

RegistryRenderernewRegistry

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

Generated using TypeDoc