make a little update

pull/144/head
Henrique Dias 2016-06-21 16:00:57 +01:00
parent c54dccec17
commit ad0f5d57fe
2 changed files with 4 additions and 4 deletions

View File

@ -165,7 +165,7 @@ func (fi FileInfo) serveSingleFile(w http.ResponseWriter, r *http.Request, c *Co
templates := []string{"single", "actions", "base"} templates := []string{"single", "actions", "base"}
for _, t := range templates { for _, t := range templates {
code, err := page.AddTemplate(t, Asset) code, err := page.AddTemplate(t, Asset, nil)
if err != nil { if err != nil {
return code, err return code, err
} }
@ -228,7 +228,7 @@ func (fi FileInfo) serveListing(w http.ResponseWriter, r *http.Request, c *Confi
templates := []string{"listing", "actions", "base"} templates := []string{"listing", "actions", "base"}
for _, t := range templates { for _, t := range templates {
code, err := page.AddTemplate(t, Asset) code, err := page.AddTemplate(t, Asset, nil)
if err != nil { if err != nil {
return code, err return code, err
} }

View File

@ -72,7 +72,7 @@ func (p PageInfo) PreviousLink() string {
} }
// AddTemplate adds a template file to the page template // AddTemplate adds a template file to the page template
func (p *Page) AddTemplate(name string, assets AssetFunc) (int, error) { func (p *Page) AddTemplate(name string, assets AssetFunc, functions template.FuncMap) (int, error) {
// Get the template from the assets // Get the template from the assets
page, err := assets("templates/" + name + ".tmpl") page, err := assets("templates/" + name + ".tmpl")
@ -86,7 +86,7 @@ func (p *Page) AddTemplate(name string, assets AssetFunc) (int, error) {
// If it's the first iteration, creates a new template and add the // If it's the first iteration, creates a new template and add the
// functions map // functions map
if p.Tpl == nil { if p.Tpl == nil {
p.Tpl, err = template.New(name).Parse(string(page)) p.Tpl, err = template.New(name).Funcs(functions).Parse(string(page))
} else { } else {
p.Tpl, err = p.Tpl.Parse(string(page)) p.Tpl, err = p.Tpl.Parse(string(page))
} }