{{- define "template" -}} {{- $name := index . 0 -}} {{- $context := index . 1 -}} {{- $v:= $context.Template.Name | split "/" -}} {{- $n := len $v -}} {{- $last := sub $n 1 | printf "_%d" | index $v -}} {{- $wtf := $context.Template.Name | replace $last $name -}} {{ include $wtf $context }} {{- end -}}