template

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DispatchHotReloadHooks

func DispatchHotReloadHooks(path string)

DispatchHotReloadHooks calls all registered hot-reload hooks for the given path.

func RegisterHotReloadHook

func RegisterHotReloadHook(hook func(path string))

RegisterHotReloadHook registers a callback that is invoked when a file is reloaded (e.g. via the REPL :reload command).

func RegisterTemplateRuntimeFactory

func RegisterTemplateRuntimeFactory(factory func(baseDir string) TemplateRuntime)

RegisterTemplateRuntimeFactory sets the factory function used to create TemplateRuntime instances.

Types

type SimpleTemplateRuntime

type SimpleTemplateRuntime struct {
	// contains filtered or unexported fields
}

SimpleTemplateRuntime implements a basic template engine for SPL

func (*SimpleTemplateRuntime) InvalidateCaches

func (r *SimpleTemplateRuntime) InvalidateCaches()

func (*SimpleTemplateRuntime) Render

func (r *SimpleTemplateRuntime) Render(tmpl string, data map[string]any) (string, error)

func (*SimpleTemplateRuntime) RenderFile

func (r *SimpleTemplateRuntime) RenderFile(path string, data map[string]any) (string, error)

func (*SimpleTemplateRuntime) RenderSSR

func (r *SimpleTemplateRuntime) RenderSSR(tmpl string, data map[string]any) (string, error)

func (*SimpleTemplateRuntime) RenderSSRFile

func (r *SimpleTemplateRuntime) RenderSSRFile(path string, data map[string]any) (string, error)

func (*SimpleTemplateRuntime) RenderStream

func (r *SimpleTemplateRuntime) RenderStream(w io.Writer, tmpl string, data map[string]any) error

func (*SimpleTemplateRuntime) RenderStreamFile

func (r *SimpleTemplateRuntime) RenderStreamFile(w io.Writer, path string, data map[string]any) error

type TemplateRuntime

type TemplateRuntime interface {
	Render(tmpl string, data map[string]any) (string, error)
	RenderFile(path string, data map[string]any) (string, error)
	RenderSSR(tmpl string, data map[string]any) (string, error)
	RenderSSRFile(path string, data map[string]any) (string, error)
	RenderStream(w io.Writer, tmpl string, data map[string]any) error
	RenderStreamFile(w io.Writer, path string, data map[string]any) error
	InvalidateCaches()
}

TemplateRuntime defines the interface for template rendering engines.

func NewSimpleTemplateRuntime

func NewSimpleTemplateRuntime(baseDir string) TemplateRuntime

NewSimpleTemplateRuntime creates a new simple template runtime

func NewTemplateRuntime

func NewTemplateRuntime(baseDir string) TemplateRuntime

NewTemplateRuntime creates a TemplateRuntime for the given base directory using the registered factory. Returns nil if no factory has been registered.

Jump to

Keyboard shortcuts

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