minor fixes for template_storage

This commit is contained in:
im7mortal 2016-04-14 00:26:45 +03:00
parent 675af529c9
commit bb0eff82a6
5 changed files with 8 additions and 8 deletions

View File

@ -7,4 +7,4 @@
<body>
{{block "body" .}} {{end}}
</body>
</html>
</html>

View File

@ -16,4 +16,4 @@ func main() {
func render(c *gin.Context) {
c.HTML(200, c.Request.URL.Path, gin.H{})
}
}

View File

@ -4,4 +4,4 @@
{{define "body"}}
<a href="/blocks2/">Go to blocks 2</a>
{{end}}
{{end}}

View File

@ -4,4 +4,4 @@
{{define "body"}}
<a href="/">Go to blocks 1</a>
{{end}}
{{end}}

View File

@ -14,20 +14,20 @@ type TemplateStorage struct {
}
func (t TemplateStorage) Instance(name string, data interface{}) Render {
return HTMLwithBlock{
return HTMLWithBlock{
Template: t.Storage[name],
Name: name,
Data: data,
}
}
type HTMLwithBlock struct {
type HTMLWithBlock struct {
Template *template.Template
Name string
Data interface{}
}
func (r HTMLwithBlock) Render(w http.ResponseWriter) error {
func (r HTMLWithBlock) Render(w http.ResponseWriter) error {
writeContentType(w, htmlContentType)
return r.Template.Execute(w, r.Data)
}
}