-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.go
46 lines (36 loc) · 838 Bytes
/
util.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
package djinn
import "fmt"
type FuncSet struct {
f map[string]interface{}
}
func NewFuncSet() *FuncSet {
return &FuncSet{make(map[string]interface{})}
}
func (f *FuncSet) AddFuncs(fns map[string]interface{}) {
for k, fn := range fns {
f.f[k] = fn
}
}
func (f *FuncSet) GetFuncs() map[string]interface{} {
return f.f
}
type xrror struct {
err string
vals []interface{}
}
func (x *xrror) Error() string {
return fmt.Sprintf(x.err, x.vals...)
}
func (x *xrror) Out(vals ...interface{}) *xrror {
x.vals = vals
return x
}
func Drror(err string) *xrror {
return &xrror{err: err}
}
var (
NilTemplateError = Drror("nil template named %s").Out
NoTemplateError = Drror("no template named %s").Out
EmptyTemplateError = Drror("empty template named %s").Out
ConfigurationError = Drror("Could not configure: %s").Out
)