go - Golang multiple template caching -


is possible render multiple html templates same name in golang. reason is, want make layout , reuse multiple views. example:

{{define "mainlayout"}} <html>    <head>     <title>{{.title}}</title>   </head>    <body>      <div>{{template "content" .}}</div>    </body>  </html> {{end}} 

content different templates, defined {{define "content"}}

i believe elithrar has looking for, unfortunately it's not supported. typical way of handling problem defining header , footer in own templates , doing inverse of approach. , can pass struct being given template parser templates render pages.

{{define "header"}} <html>... {{end}}  {{define "footer"}} ...</html> {{end}}  {{define "content"}} {{template "header" .}} html {{template "footer" .}} {{end}} 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -