MCPcopy
hub / github.com/helm/helm / includeFun

Function includeFun

pkg/engine/engine.go:132–149  ·  view source on GitHub ↗

'include' needs to be defined in the scope of a 'tpl' template as well as regular file-loaded templates.

(t *template.Template, includedNames map[string]int)

Source from the content-addressed store, hash-verified

130// 'include' needs to be defined in the scope of a 'tpl' template as
131// well as regular file-loaded templates.
132func includeFun(t *template.Template, includedNames map[string]int) func(string, any) (string, error) {
133 return func(name string, data any) (string, error) {
134 var buf strings.Builder
135 if v, ok := includedNames[name]; ok {
136 if v > recursionMaxNums {
137 return "", fmt.Errorf(
138 "rendering template has a nested reference name: %s: %w",
139 name, errors.New("unable to execute template"))
140 }
141 includedNames[name]++
142 } else {
143 includedNames[name] = 1
144 }
145 err := t.ExecuteTemplate(&buf, name, data)
146 includedNames[name]--
147 return buf.String(), err
148 }
149}
150
151// As does 'tpl', so that nested calls to 'tpl' see the templates
152// defined by their enclosing contexts.

Callers 2

tplFunFunction · 0.85
initFunMapMethod · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…