Created
February 10, 2014 02:06
-
-
Save jonathaningram/8909167 to your computer and use it in GitHub Desktop.
Illustrates the Golang error "template: redefinition of template %q"
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
{{ define "layout" }} | |
<html> | |
<body> | |
{{ template "navbar" . }} | |
<div class="content"> | |
{{ template "content" . }} | |
</div> | |
</body> | |
</html> | |
{{ end }} | |
{{ define "navbar" }} | |
<div class="navbar1"> | |
this is navbar 1, the default for the site | |
</div> | |
{{ end }} | |
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
{{ template "layout" . }} | |
{{ /* this is illegal because "navbar" is already defined */ }} | |
{{ define "navbar" }} | |
<div class="navbar2"> | |
this is navbar 2, only for this special page - maybe it's a slimmed down version, or has different links | |
</div> | |
{{ end }} | |
{{ define "content" }} | |
the content for special page | |
{{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment