|
|
|
|
|
by mbivert
750 days ago
|
|
> because of the lack of being able to pass multiple arguments to a template I'm not sure if this I understand the issue correctly, but one can pass multiple arguments, by wrapping them e.g. into a hash (https://go.dev/play/p/89gP42K8XRb): package main
import (
"log"
"os"
"text/template"
)
func main() {
err := template.Must(
template.New("").Parse("{{ .greeting }}, {{ .user.name }}!"),
).Execute(os.Stdout, map[string]any{
"user": map[string]any{
"name": "earthling",
},
"greeting": "hello",
})
if err != nil {
log.Fatal(err)
}
}
In my experience, the module is far from a toy, but it's not always obvious how to use it properly, at first. |
|