Skip to content

Instantly share code, notes, and snippets.

@boushley
Last active August 29, 2015 14:01
Show Gist options
  • Save boushley/7a080798978ae1064192 to your computer and use it in GitHub Desktop.
Save boushley/7a080798978ae1064192 to your computer and use it in GitHub Desktop.
Go Templates With Dynamic Template
<div>
{{ $foobar := printf `chrome/author/%s.html` .Params.author }}
{{ $foobar }} <!-- This prints "chrome/author/name.html" -->
{{ template $foobar . }} <!-- This blows up -->
{{ template "chrome/author/" + .Params.author + ".html" . }} <!-- This blows up -->
</div>
<div>
{{ if eq .Params.author "boushley" }}
{{ template "chrome/author/boushley.html" . }}
{{ else if ... }}
...
{{ end }}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment