-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deprecated.go
executable file
·49 lines (41 loc) · 1.11 KB
/
deprecated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package view
import (
"net/http"
)
// RenderContext is the type passed in to New, which helps construct the rendering view
// Alternatively, you can use NewWithPath, which doesn't require a RenderContext
type RenderContext interface {
Path() string
RenderContext() map[string]interface{}
Writer() http.ResponseWriter
}
// New creates a new Renderer
func New(c RenderContext) *Renderer {
r := &Renderer{
path: c.Path(),
layout: "app/views/layout.html.got",
template: "",
format: "text/html",
status: http.StatusOK,
context: c.RenderContext(),
writer: c.Writer(),
}
// This sets layout and template based on the view.path
r.setDefaultTemplates()
return r
}
// NewWithPath creates a new Renderer with a path and an http.ResponseWriter
func NewWithPath(p string, w http.ResponseWriter) *Renderer {
r := &Renderer{
path: p,
layout: "app/views/layout.html.got",
template: "",
format: "text/html",
status: http.StatusOK,
context: make(map[string]interface{}, 0),
writer: w,
}
// This sets layout and template based on the view.path
r.setDefaultTemplates()
return r
}