-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
44 lines (37 loc) · 846 Bytes
/
config.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
package templates
import "io/fs"
type Configuration struct {
TemplatesFS *fs.FS
Formats Formats
CommonTemplatesPath *string
}
type Format int
const (
Html Format = iota
Text
)
type Formats map[Format]*FormatOptions
type FormatOptions struct {
FileExtension string
IsRequired bool
}
// NewConfiguration creates a default configuration that can be changed
func NewConfiguration(templatesFS *fs.FS) *Configuration {
return &Configuration{
TemplatesFS: templatesFS,
Formats: Formats{
Html: &FormatOptions{
FileExtension: "html",
IsRequired: true,
},
Text: &FormatOptions{
FileExtension: "txt",
IsRequired: false,
},
},
}
}
// SetCommonTemplatesPath sets common templates path
func (c *Configuration) SetCommonTemplatesPath(path string) {
c.CommonTemplatesPath = &path
}