-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.go
61 lines (49 loc) · 1.34 KB
/
configuration.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
50
51
52
53
54
55
56
57
58
59
60
61
package core
import (
"io"
"github.com/karlseguin/bytepool"
)
var BytePool = bytepool.New(128, 4096)
// cache interface
type Cache interface {
Get(key string) Code
Set(key string, template Code)
Clear()
}
// The callback to execute to resolve include tags
// If you're going to use name to read from the filesystem, beware of directory
// traversal.
type IncludeHandler func(name string, writer io.Writer, data map[string]interface{})
// Configuration used for generating a template
type Configuration struct {
cache Cache
includeHandler IncludeHandler
preserveWhitespace bool
}
// Set the caching engine, or nil for no caching
func (c *Configuration) Cache(cache Cache) *Configuration {
c.cache = cache
return c
}
// Gets the configured cache
func (c *Configuration) GetCache() Cache {
return c.cache
}
// Set the include handler
func (c *Configuration) IncludeHandler(handler IncludeHandler) *Configuration {
c.includeHandler = handler
return c
}
// Gets the configured include handler
func (c *Configuration) GetIncludeHandler() IncludeHandler {
return c.includeHandler
}
// Preserves whitespace
func (c *Configuration) PreserveWhitespace() *Configuration {
c.preserveWhitespace = true
return c
}
// Gets the preserves whitespace value
func (c *Configuration) GetPreserveWhitespace() bool {
return c.preserveWhitespace
}