Isset function adding whitespace if false

I’m trying to add content as follows:

{{ if isset .Params "journal" }}<i>{{- .Params.journal -}}</i>{{ end }}
{{ if isset .Params "booktitle" }}<i>{{- .Params.booktitle -}}</i>{{ end }}
{{ if isset .Params "volume" }}{{- .Params.volume -}}{{ end }}
{{ if isset .Params "issue" }}({{- .Params.issue -}}){{ end }}

The rendered version adds whitespace if the isset is evaluated to false. Is there any way I can avoid this?


it is probably intuitive for many but it was not for me so if you want to avoid any whitespace character you should add dash to every part of the if-then close so {{- if … -}} and {{- end -}} should also have the dashes and to be sure if you have the long list of if-then clauses do that for the ones outlining too (or short: do it for every {{ if }}/{{ end }} you can find in your templates until it breaks ;))…

i tried to find a good source of the behavior of the dashes in templates with a lot of logical blocks but so far couldn’t find the good specification… most of the references are just mentioning the case in which the variable is in between the {{ brackets }}… for the time being before doing a proper set of tests i would stick to making my habit into {{- -}} instead of {{ }}…