Skip to content

Instantly share code, notes, and snippets.

@andrebq
Created December 7, 2011 12:08
Show Gist options
  • Save andrebq/1442579 to your computer and use it in GitHub Desktop.
Save andrebq/1442579 to your computer and use it in GitHub Desktop.
Go Template test
Executing...
<ul></ul> Broken tag</ul>
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