Skip to content

Instantly share code, notes, and snippets.

@moraes
Created January 1, 2013 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moraes/4427246 to your computer and use it in GitHub Desktop.
Save moraes/4427246 to your computer and use it in GitHub Desktop.
text/template composition using {{block}} and {{fill}
// A base template with the layout skeleton.
// {{block}} actions define placeholders.
{{define "base"}}
<html>
<head>
<title>{{block "title"}}</title>
</head>
<body>
{{block "content"}}
</body>
</html>
{{end}}
// A template that fills the base template ("page1 extends base").
// {{fill}} actions fill the blocks defined in the base template.
{{define "page1" "base"}}
{{fill "title"}}Page 1{{end}}
{{fill "content"}}This is Page 1.{{end}}
{{end}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment