<p>Using the helm <a href="https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function" rel="nofollow noreferrer">function tpl</a> or other similar functions, how do you pass in a <a href="https://helm.sh/docs/chart_template_guide/variables/" rel="nofollow noreferrer">file specific variable</a> and the <a href="https://helm.sh/docs/chart_template_guide/values_files/" rel="nofollow noreferrer">top level Values</a>? Here is a concrete example:</p>
<pre><code># values
template: &quot;{{ .Values.name }} drinks {{ $drink }}&quot;
name: &quot;Tom&quot;

# template
{{- $drink := &quot;coffee&quot; -}}
# how do I pass $drink into tpl???
{{ tpl .Values.template . }}

# expected output
Tom drinks coffee
</code></pre>
<p>It seems like when I do this it just passes in the <code>.Values</code>, but not the file specific <code>$drink</code> variable that's defined within the template and I get the error: <code>error calling tpl</code>. I don't see anything in the docs for how to merge these values together or just pass them both into the function.</p>

jjbskir
<p>Helm is using a slightly modified version of sprig functions. Most things from sprig are available.</p>
<p>You can use one of the <a href="http://masterminds.github.io/sprig/dicts.html" rel="nofollow noreferrer">dict functions</a> to set the value or create a new dict that you pass as context.</p>
<pre><code>{{ $_ := set .Values &quot;drink&quot; $drink }}
{{ tpl .Values.template . }}
</code></pre>
<p>In this case I have set a new key on the <code>Values</code> dict.</p>
<pre class="lang-yaml prettyprint-override"><code>template: &quot;{{ .Values.name }} drinks {{ .Values.drink }}&quot;
</code></pre>
