Page render html takes only the neccessary arguments

pull/144/head
Henrique Dias 2017-06-27 09:40:33 +01:00
parent 2df4efc369
commit 3b3643be05
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
3 changed files with 6 additions and 5 deletions

View File

@ -125,10 +125,10 @@ func serveSingle(w http.ResponseWriter, r *http.Request, c *FileManager, u *User
return http.StatusInternalServerError, err
}
return p.PrintAsHTML(w, c, "frontmatter", "editor")
return p.PrintAsHTML(w, c.assets.templates, "frontmatter", "editor")
}
return p.PrintAsHTML(w, c, "single")
return p.PrintAsHTML(w, c.assets.templates, "single")
}
func editorClass(mode string) string {

View File

@ -90,7 +90,7 @@ func serveListing(w http.ResponseWriter, r *http.Request, c *FileManager, u *Use
Data: listing,
}
return p.PrintAsHTML(w, c, "listing")
return p.PrintAsHTML(w, c.assets.templates, "listing")
}
// handleSortOrder gets and stores for a Listing the 'sort' and 'order',

View File

@ -9,6 +9,7 @@ import (
"net/http"
"strings"
rice "github.com/GeertJohan/go.rice"
"github.com/hacdias/filemanager/variables"
)
@ -102,7 +103,7 @@ func (p page) PreviousLink() string {
}
// PrintAsHTML formats the page in HTML and executes the template
func (p page) PrintAsHTML(w http.ResponseWriter, m *FileManager, templates ...string) (int, error) {
func (p page) PrintAsHTML(w http.ResponseWriter, box *rice.Box, templates ...string) (int, error) {
templates = append(templates, "actions")
templates = append(templates, "templates")
@ -117,7 +118,7 @@ func (p page) PrintAsHTML(w http.ResponseWriter, m *FileManager, templates ...st
// For each template, add it to the the tpl variable
for i, t := range templates {
// Get the template from the assets
Page, err := m.assets.templates.String(t + ".tmpl")
Page, err := box.String(t + ".tmpl")
// Check if there is some error. If so, the template doesn't exist
if err != nil {