jeudi 5 mars 2015

tmpl.Execute and sub-file golang


Vote count:

0




i need help. I need to use "html/template"'s marking({{.Title}}, example) in sub-files("article.html", example in my text)



...
type Page struct {
Test string
}

type News struct {
Page
Title string
}
t, _ := template.ParseFiles(filepath+"core.tmpl", filepath+"article.tmpl")
p := &News{
Title: "TITLE",
Page: Page{
Test: "TITLE",
},
}
t.Execute(wr, p)


Code in core.tmpl



{{template "article"}}


Code in article.tmpl



{{define "article"}}
{{.Title}}<br><br>
{{.Page.Test}}
{{end}}


asked 23 secs ago







tmpl.Execute and sub-file golang

Aucun commentaire:

Enregistrer un commentaire