<p>I have been asked to modify a Helm template to accommodate a few changes to check if a value is empty or not as in the code snippet below. I need to check <code>$var.alias</code> inside the <code>printf</code> in the code snippet and write custom logic to print a custom value. Any pointers around the same would be great.</p>
<pre><code>{{- range $key, $value := .Values.testsConfig.keyVaults -}}
{{- range $secret, $var := $value.secrets -}}
{{- if nil $var.alias}}
{{- end -}}
{{ $args = append $args (printf &quot;%s=/mnt/secrets/%s/%s&quot; $var.alias $key $var.name | quote) }}
{{- end -}}
{{- end -}}
</code></pre>

<p>I decided to test what madniel wrote in his comment. Here are my files:</p>
<p>values.yaml</p>
<pre><code>someString: abcdef
emptyString: &quot;&quot;
# nilString:
</code></pre>
<p>templates/test.yaml</p>
<pre><code>{{ printf &quot;someEmptyString=%q)&quot; .Values.someString }}
{{ printf &quot;emptyString=%q)&quot; .Values.emptyString }}
{{ printf &quot;nilString=%q)&quot; .Values.nilString }}

{{- if .Values.someString }}
{{ printf &quot;someString evaluates to true&quot; }}
{{- end -}}

{{- if .Values.emptyString }}
{{ printf &quot;emptyString evaluates to true&quot; }}
{{- end -}}

{{- if .Values.nilString }}
{{ printf &quot;nilString evaluates to true&quot; }}
{{- end -}}

{{- if not .Values.emptyString }}
{{ printf &quot;not emptyString evaluates to true&quot; }}
{{- end -}}

{{- if not .Values.nilString }}
{{ printf &quot;not nilString evaluates to true&quot; }}
{{- end -}}
</code></pre>
<p>Helm template output:</p>
<pre><code>➜  helm template . --debug
install.go:173: [debug] Original chart version: &quot;&quot;
install.go:190: [debug] CHART PATH: &lt;REDACTED&gt;

---
# Source: asd/templates/test.yaml
someEmptyString=&quot;abcdef&quot;)
emptyString=&quot;&quot;)
nilString=%!q(&lt;nil&gt;))
someString evaluates to true
not emptyString evaluates to true
not nilString evaluates to true
</code></pre>
<p>So yes, it should work if you use <code>{{ if $var.alias }}</code></p>
