MCPcopy
hub / github.com/pocketbase/pocketbase / Render

Method Render

tools/template/renderer.go:17–33  ·  view source on GitHub ↗

Render executes the template with the specified data as the dot object and returns the result as plain string.

(data any)

Source from the content-addressed store, hash-verified

15// Render executes the template with the specified data as the dot object
16// and returns the result as plain string.
17func (r *Renderer) Render(data any) (string, error) {
18 if r.parseError != nil {
19 return "", r.parseError
20 }
21
22 if r.template == nil {
23 return "", errors.New("invalid or nil template")
24 }
25
26 buf := new(bytes.Buffer)
27
28 if err := r.template.Execute(buf, data); err != nil {
29 return "", err
30 }
31
32 return buf.String(), nil
33}

Callers 5

TestRegistryAddFuncsFunction · 0.80
TestRegistryLoadFilesFunction · 0.80
TestRegistryLoadStringFunction · 0.80
TestRegistryLoadFSFunction · 0.80
TestRendererRenderFunction · 0.80

Calls 2

ExecuteMethod · 0.80
StringMethod · 0.45

Tested by 5

TestRegistryAddFuncsFunction · 0.64
TestRegistryLoadFilesFunction · 0.64
TestRegistryLoadStringFunction · 0.64
TestRegistryLoadFSFunction · 0.64
TestRendererRenderFunction · 0.64