Created
December 7, 2011 12:08
Go Template test
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
Executing... | |
<ul></ul> Broken tag</ul> |
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 ( | |
"html/template" | |
"os" | |
"fmt" | |
) | |
type Test struct { | |
Title string | |
} | |
var tmpl1 string = ` | |
{{define "inner"}}</ul> Broken tag{{end}} | |
{{define "outter"}}<ul>{{template "inner" . }}</ul>{{end}} | |
{{template "outter" .}} | |
` | |
func main() { | |
t := template.New("test") | |
_, err := t.Parse(tmpl1) | |
if err != nil { | |
panic(err) | |
} | |
data := Test{Title:"This is the title"} | |
fmt.Printf("Executing...") | |
t.Execute(os.Stdout, data) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment