templatereloader

package
v0.106.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 6 Imported by: 2

README

templatereloader

A templatereloader is a jaws.TemplateLookuper that will reload templates from disk as needed if running with -tags debug or -race. If not, it simply calls template.New("").ParseFS(fsys, fpath) and has no overhead.

For example usage, see jawsboot/README.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(fsys fs.FS, fpath, relpath string) (jtl jaws.TemplateLookuper, err error)

New returns a jaws.TemplateLookuper.

If deadlock.Debug is false, it calls template.New("").ParseFS(fsys, fpath).

If deadlock.Debug is true, fsys is ignored and it returns a TemplateReloader that loads the templates using ParseGlob(relpath/fpath).

Types

type TemplateReloader

type TemplateReloader struct {
	Path string // the file path we are loading from
	// contains filtered or unexported fields
}

A TemplateReloader reloads and reparses templates if more than one second has passed since the last Lookup.

func (*TemplateReloader) Lookup

func (tr *TemplateReloader) Lookup(name string) *template.Template

Jump to

Keyboard shortcuts

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