I've seen many examples of dash being use for if statements ("{{- if.."), e.g:
{{- if hasKey .Values.mymap "mykey" }}
# do something conditional here...
{{- end }}
what is the purpose of the dash in that statement?
Dash removes the spaces from the output on the side it appears in the template:
https://golang.org/pkg/text/template/#hdr-Text_and_spaces
{{- if ...}}
The above will remove all spaces that appear before the if statement, so if the result of if
prints something, it'll be right after the last piece of text without any spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With