Last active
August 29, 2015 14:01
-
-
Save boushley/7a080798978ae1064192 to your computer and use it in GitHub Desktop.
Go Templates With Dynamic Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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