Executing templates

59 views
Skip to first unread message

Денис Мухортов

unread,
Oct 26, 2021, 1:39:04 PM10/26/21
to golang-nuts
  I can't include templates in html. A strange thing happens for me:
when viewing in devtools, I see that everything is parsed first except the template,
and then the template itself. Although it is included in the tag in the middle of the file. Most likely, this is due to the fact that I wrote this in go:

tmp := template.Must(template.ParseFiles(files...))
stone Shop := stones()
err = temp.Execute(w, block)
if err != nil {
log.Fatal(error)
}
err = temp.ExecuteTemplate(w, "stone", stoneShop)
if err != nil {
log.Print(err)
}

I need to transfer different data (block, stoneShop) to one page, and stoneShop is used in the template. Perhaps because of the double Execute call, such an oddity occurs. How can this be implemented at all, if not so? If you need more information, then my git: https://github.com/MukhortovDenis/goproject/tree/liltest , where are the functions in handlers.go
Reply all
Reply to author
Forward
0 new messages