Documentation
¶
Overview ¶
Package template contains methods that will template go text/templates files that may contain sjs snippets.
Index ¶
- type Context
- type ReadFunc
- type Templator
- func (t *Templator) Recurse(_ VM, numTimes int) (out string, err error)
- func (t *Templator) SetContextData(contextData any, globalComputed goja.Value)
- func (t *Templator) TemplateFile(ctx context.Context, vm VM, templateFile, outFile string, inputData any) error
- func (t *Templator) TemplateString(ctx context.Context, vm VM, templatePath string, inputData any) (out string, err error)
- func (t *Templator) TemplateStringInput(ctx context.Context, vm VM, name string, input string, inputData any) (out string, err error)
- type VM
- type WriteFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Global any Local any GlobalComputed goja.Value LocalComputed goja.Value RecursiveComputed goja.Value }
Context is the context that is passed templates or js.
type Templator ¶
type Templator struct { WriteFunc WriteFunc ReadFunc ReadFunc TmplFuncs map[string]any Debug bool // contains filtered or unexported fields }
Templator extends the go text/template package to allow for sjs snippets.
func (*Templator) Recurse ¶ added in v0.8.0
Recurse will let the engine know how many times the template should execute.
func (*Templator) SetContextData ¶ added in v0.4.0
SetContextData allows the setting of global context for templating.
func (*Templator) TemplateFile ¶
func (t *Templator) TemplateFile(ctx context.Context, vm VM, templateFile, outFile string, inputData any) error
TemplateFile will template a file and write the output to outFile.
Click to show internal directories.
Click to hide internal directories.