Added the Context to the browse directive

Moved the Context type to middleware and exported it.
Users can use .Include and others in browse directive templating
Created test for the templates directive.
This commit is contained in:
Maxime
2015-07-17 20:07:24 +02:00
parent fcf2622c26
commit f536bc94b2
10 changed files with 165 additions and 32 deletions

View File

@ -31,7 +31,7 @@ func (t Templates) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
for _, ext := range rule.Extensions {
if reqExt == ext {
// Create execution context
ctx := context{root: t.FileSys, req: r, URL: r.URL}
ctx := middleware.Context{Root: t.FileSys, Req: r, URL: r.URL}
// Build the template
tpl, err := template.ParseFiles(filepath.Join(t.Root, fpath))