Fix errors arising from short-circuit assumption

The and/or operators in text/template don't short-circuit, so this
seemingly benign change caused a breakage when not fully tested.
This commit is contained in:
Drew DeVault 2020-10-23 15:19:16 -04:00
parent 64b16f4a50
commit bd91b3eacf

View file

@ -178,7 +178,9 @@
{{ $html := .Message.HTMLPart }}
{{ $text := .Message.TextPart }}
<div class="tabs">
{{ if and $html (ne $html.PathString $text.PathString) }}
{{ if and $html $text }}
{{ if ne $html.PathString $text.PathString }}
{{/* https://github.com/golang/go/issues/31103 */}}
<a
href="?part={{.Message.TextPart.PathString}}"
{{ if eq $text.PathString .Part.PathString }}
@ -192,6 +194,7 @@
{{ end }}
>HTML</a>
{{ end }}
{{ end }}
</div>
{{if .View}}
{{.View}}