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?
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.
-
before the closing bracket? does it make any difference? –
Eal {{ end -}} \n {{ end }}
vs {{ end }} \n {{- end }}
is there any difference, and which is preferable? –
Eal © 2022 - 2024 — McMap. All rights reserved.