MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / processTemplate

Function processTemplate

util/template.go:39–52  ·  view source on GitHub ↗

processTemplate processes the template with the given name and data. It returns the resulting bytes.Buffer or an error if the template execution fails.

(name string, data map[string]any)

Source from the content-addressed store, hash-verified

37// processTemplate processes the template with the given name and data.
38// It returns the resulting bytes.Buffer or an error if the template execution fails.
39func processTemplate(name string, data map[string]any) (*bytes.Buffer, error) {
40 t, ok := templates[name]
41 if !ok {
42 return nil, fmt.Errorf("template %s not found", name)
43 }
44
45 var tpl bytes.Buffer
46
47 if err := t.Execute(&tpl, data); err != nil {
48 return nil, err
49 }
50
51 return &tpl, nil
52}
53
54// GetTemplateByString returns the parsed template as a string.
55// It returns an error if the template processing fails.

Callers 3

TestProcessTemplateFunction · 0.85
GetTemplateByStringFunction · 0.85
GetTemplateByBytesFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestProcessTemplateFunction · 0.68