I'm trying to create a go html (Go 1.13) with a context {{.}}.
I've managed to display context variables as div values, but I can't find the right way to put context variables inside HTML attributes.
For instance, this code works:
{{ if .AppCtx.Title }}
<a href="/">{{ .AppCtx.Title }}</a>
{{end}}
But this does not seem to work :
<a href="{{ if .AppCtx.Link }}{{.AppCtx.Link}} {{end}}">
I' ve tried different syntaxes :
- single quotes :
<a href='{{ if .AppCtx.Link }}{{.AppCtx.Link}} {{end}}'>
- double quotes in front of the conditional statement:
<a href=""{{ if .AppCtx.Link }}{{.AppCtx.Link}} {{end}}>
- double quotes around :
<a href="{{ if .AppCtx.Link }}{{.AppCtx.Link}} {{end}}">
I've read https://golang.org/pkg/html/template/ but didn't find any clue in it.