N
N
Newmo2019-04-18 11:14:32
go
Newmo, 2019-04-18 11:14:32

How to pass two structures to a template?

I pass one structure to the template: How can I pass two? something like this: What would be called in the template already by parameters: {{.products.Item}} and, accordingly {{.products2.Item}}
ExecuteTemplate(w, "single", products)
ExecuteTemplate(w, "single", products, products2)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abmanimenja, 2019-04-18
@Newmo

type C struct {
   Products T1
   Products2 T2
}


var c C

Execute(w, c)

What would be called in the template already by parameters:
{{.products.Item}} and, accordingly, {{.products2.Item}}

Capitalized only
and
.Products2.Item

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question