For another alternative which I think is more flexible, look at the
{{block}} syntax. This lets you define multiple sections that can be
overridden by an extending template. Example (untested):
-- layout.html
<title>{{block title}}My default title{{end}}</title
<script>
{{block scripts}}
{{end}}
</script>
<div>
{{block content}}
{{end}}
</div>
-- view.html
{{extend "layout.html"}}
{{block title}}My new title{{end}}
{{block scripts}}
function foo() { return 1; }}
{{end}}
{{block content}}
Hello world!
{{end}}
In this case, "My default title" would be replaced by "My new title" (but it
would remain "My default title" if you did not specify a title block in
view.html). The script and content values also get filled in as you would
expect.
Cheers,
Kevin