You can easily do this:
t := templates.New("Id").Parse(whatever_source_string)
t.New("Id2").Parse(whatever_other_thing)
...
t.Execute(writer, data)
Any of the source strings may contain multiple {{define}} elements, so long as they all resolve at the end.
eg.
index file:
{{ define "Content" }}
stuff
{{ end }}
{{ define "Scripts" }}
other stuff
{{ end }}
{{ template "_layout" . }}
layout file:
{{ define "_layout" }}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Frag!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Styles -->
{{ template "_styles" . }}
</head>
<body>
<!-- Header -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="{{ .Urls.FragmentIndex }}">Fragments</a>
</div>
</div>
</div> <!-- /navbar -->
<!-- Content -->
<div class="container">
{{ template "Content" . }}
</div> <!-- /container -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="
http://code.jquery.com/jquery.js"></script>
<script src="/assets/js/bootstrap.js"></script>
{{ template "Scripts" . }}
</body>
</html>
{{ end }}
~
Doug.