I am writing a web application in GoLang, not using any framework.
I am trying to create a layout
similar to layouts in nodejs, for example.
=== layout.html ====
{{ define "layout"}}
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href="/static/style.css" rel="stylesheet" media="all" type="text/css">
</head>
<body>
{{ template "content"}}
</body>
</html>
{{ end }}
I then have my some content in say home.html
{{ define "content"}}
<h1>{{.Title}}</h1>
<div>This is a test</div>
{{ end }}
I have 2 problems with this approach
(1) my Execute template code, does not seem to be passing the data to the content
templates.ExecuteTemplate(w, "layout", &Page{Title: "Home", Body: nil})
(2) If I want to have multiple pages with the same layout, the above will not work as it does not specify which content to load.
Can someone please explain a strategy for using tempates and 'layouts' in GoLang ?