Created
February 6, 2013 20:54
-
-
Save gregworley/4725728 to your computer and use it in GitHub Desktop.
trying to use gorilla template with slots and fills
This file contains hidden or 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
package main | |
import ( | |
template "github.com/gorilla/template/v0" | |
"fmt" | |
"os" | |
) | |
func main() { | |
set, err := new(template.Set).Parse(`{{define "slot"}} | |
{{slot "header"}} | |
{{template "slot_header"}} | |
{{end}} | |
{{slot "content"}} | |
slot content | |
{{end}} | |
{{slot "footer"}} | |
slot footer | |
{{end}} | |
{{end}} | |
{{define "slot_header"}} | |
a header | |
{{end}} | |
{{define "page1"}} | |
{{fill "slot"}} | |
{{slot "header"}} | |
{{template "slot_header"}} | |
page1 header | |
{{end}} | |
{{slot "content"}} | |
page1 content | |
{{end}} | |
{{end}} | |
{{end}}`) | |
if err != nil { | |
fmt.Print(err) | |
} | |
err = set.Execute(os.Stderr, "page1", nil) | |
if err != nil { | |
fmt.Print(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This isn't outputting anything for me.