Using Template Blocks In go

32 views Asked by At

I have multiple files inside ./views folder, _layout.html, view.html and search.html in _layout.html I have {{template "PageCSS" .}} and in view.html and search.html I customized it by {{define "PageCSS"}}....{{end}} and my go code is

tmpl := iris.HTML("./views", ".html")
tmpl.Layout("\_layout.html")
rp.RegisterView(tmpl)


rp.Get("/search", func(ctx iris.Context) {
    ctx.View("search.html")
})
rp.Get("/view", func(ctx iris.Context) {
    ctx.View("view.html")
})`

but when I run it and go to search page I see view.html {{define "PageCSS"}}....{{end}} part what should I do? in fact it renders {{define "PageCSS"}}....{{end}} part of last .html file in ./views folder for all other .html files

I tried this in Iris doc

0

There are 0 answers