summaryrefslogtreecommitdiff
path: root/options.go
blob: a047f0cd78abde0f584f046e82df69b8772c28b8 (plain)
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
package templates

type Option func(*Templates) error

func Map(m []Mapping) Option {
	return func(t *Templates) error {
		t.mappings = m
		return nil
	}
}

func Base(s string) Option {
	return func(t *Templates) error {
		t.base = s
		return nil
	}
}

func Debug(f func(...interface{})) Option {
	return func(t *Templates) error {
		log = f
		log("debugging templates")
		return nil
	}
}

func Extensions(e []string) Option {
	return func(t *Templates) error {
		t.extensions = e
		return nil
	}
}

func Package(p string) Option {
	return func(t *Templates) error {
		t.pkg = p
		return nil
	}
}

func EnableHTMLTemplates() Option {
	return func(t *Templates) error {
		t.htmlTmpl = true
		return nil
	}
}

func EnableTextTemplates() Option {
	return func(t *Templates) error {
		t.textTmpl = true
		return nil
	}
}

func FunctionPrefix(p string) Option {
	return func(t *Templates) error {
		t.prefix = p
		return nil
	}
}