MCPcopy Index your code
hub / github.com/tinode/chat / ExecuteTemplate

Function ExecuteTemplate

server/validate/validator.go:81–103  ·  view source on GitHub ↗
(template *template.Template, parts []string, params map[string]any)

Source from the content-addressed store, hash-verified

79}
80
81func ExecuteTemplate(template *template.Template, parts []string, params map[string]any) (map[string]string, error) {
82 content := map[string]string{}
83 buffer := new(bytes.Buffer)
84
85 if parts == nil {
86 if err := template.Execute(buffer, params); err != nil {
87 return nil, err
88 }
89 content[""] = buffer.String()
90 } else {
91 for _, part := range parts {
92 buffer.Reset()
93 if templBody := template.Lookup(part); templBody != nil {
94 if err := templBody.Execute(buffer, params); err != nil {
95 return nil, err
96 }
97 }
98 content[part] = buffer.String()
99 }
100 }
101
102 return content, nil
103}
104
105func ResolveTemplatePath(path string) (string, error) {
106 if filepath.IsAbs(path) {

Callers 4

RequestMethod · 0.92
ResetSecretMethod · 0.92
RequestMethod · 0.92
ResetSecretMethod · 0.92

Calls 2

StringMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…