I have an if else block in my template. when else if
is true it is rendered always empty as if else
or else if
is not there
here is my template
in this case, it renders nothing
And also I am using text/template
because html/template
send the page completely empty
//the template
<script>
{{if.PassChange}}
swal("{{.Lang.Success}}", "{{.Lang.PleaseLogin}}", "success")
{{end}}
{{if.UserExists}}
swal("{{.Lang.Fail}}", "{{.Lang.AlreadyMember}}", "error")
{{end}}
</script>
//rendering part
BasePath.Get("/", func(w http.ResponseWriter, r *http.Request) {
tpl.ExecResponse(w, struct{Lang map[string]string ; UserExists bool}{Lang:lang.GetLang(r),UserExists:true})
})
If you print the error from executing the template, you will find that the template cannot evaluate the field
PassChange
. One possible fix is to add a PassChange field to the struct.