Skip to content

Commit

Permalink
fixed helm#7111
Browse files Browse the repository at this point in the history
  • Loading branch information
zwwhdls committed Nov 29, 2019
1 parent 22e00be commit 20d0a6e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/engine/engine.go
Expand Up @@ -93,11 +93,19 @@ func warnWrap(warn string) string {
// initFunMap creates the Engine's FuncMap and adds context-specific functions.
func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]renderable) {
funcMap := funcMap()
includedNames := make([]string, 0)

// Add the 'include' function here so we can close over t.
funcMap["include"] = func(name string, data interface{}) (string, error) {
var buf strings.Builder
for _, n := range includedNames {
if n == name {
return "", errors.Wrapf(fmt.Errorf("unable to excute template"), "rendering template in a loop, name: %s", name)
}
}
includedNames = append(includedNames, name)
err := t.ExecuteTemplate(&buf, name, data)
includedNames = includedNames[:len(includedNames)-1]
return buf.String(), err
}

Expand Down

0 comments on commit 20d0a6e

Please sign in to comment.