forked from veonik/squircy2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.go
43 lines (33 loc) · 757 Bytes
/
loader.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
// +build !debug
package squircy
import (
"bytes"
"io"
"github.com/go-martini/martini"
"github.com/martini-contrib/staticbin"
"github.com/tyler-sommer/stick"
)
type stringTemplate struct {
name string
contents string
}
func (t *stringTemplate) Name() string {
return t.name
}
func (t *stringTemplate) Contents() io.Reader {
return bytes.NewBufferString(t.contents)
}
func newTemplateLoader() stick.Loader {
return &assetLoader{}
}
type assetLoader struct{}
func (l *assetLoader) Load(name string) (stick.Template, error) {
res, err := Asset("views/" + name)
if err != nil {
return nil, err
}
return &stringTemplate{name, string(res)}, nil
}
func newStaticHandler() martini.Handler {
return staticbin.Static("public", Asset)
}