title: Helm _helpers.tpl: Calling defined templates in other template definitions
body: <h1>Helm _helpers.tpl?</h1>
  
  <p>Helm allows for the use of <a href="https://golang.org/pkg/text/template/" rel="noreferrer">Go templating</a> in resource files for Kubernetes.  </p>
  
  <p>A file named <code>_helpers.tpl</code> is usually used to define Go template helpers with this syntax:</p>
  
  <pre><code>{{- define "yourFnName" -}}
  {{- printf "%s-%s" .Values.name .Values.version | trunc 63 -}}
  {{- end -}}
  </code></pre>
  
  <p>Which you can then use in your <code>*.yaml</code> resource files like so:</p>
  
  <pre><code>{{ template "yourFnName" . }}
  </code></pre>
  
  <h1>The Question</h1>
  
  <p>How can I use the helpers I define, in other helper definitions?  </p>
  
  <p>For example, what if I have a helper for the application name, and want to use that in the definition for a helper which determines the ingress host name?  </p>
  
  <p>I have tried calling helpers in other definitions a couple different ways. Given this basic helper function:</p>
  
  <pre><code>{{- define "host" -}}
  {{- printf "%.example.com" &lt;Somehow get result of "name" helper here&gt; -}}
  {{- end -}}
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>{{- printf "%.example.com" {{ template "name" . }} -}}
  {{- printf "%.example.com" {{- template "name" . -}} -}}
  {{- printf "%.example.com" ( template "name" . ) -}}
  {{- printf "%.example.com" template "name" . -}}
  # Separator
  {{- $name := {{ template "environment" . }} -}}
  {{- printf "%.example.com" $name -}}
  # Separator
  {{- $name := template "environment" . -}}
  {{- printf "%.example.com" $name -}}
  # Separator
  {{- $name := environment -}}
  {{- printf "%.example.com" $name -}}
  </code></pre>
  
  <p>Is it possible to even do this? If so, how?</p>