-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.go
47 lines (41 loc) · 934 Bytes
/
format.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
/* Copyright 2019 Kilobit Labs Inc. */
package elements // import "kilobit.ca/go/elements"
// Definition for simple functions that format the element.
//
type Formatter func(s string) string
// Format for the element.
//
type Format struct {
Close bool // Self closing
Sep string // Separator
Prefix string
CPrefix string // Child Prefix
TagFmt Formatter
TagOpen string
TagClose string
EndTagOpen string
EndTagClose string
AttrSep string
AttrKFmt Formatter
AttrVFmt Formatter
}
func IDString(s string) string {
return s
}
func QuoteString(s string) string {
return "\"" + s + "\""
}
var defaultFormat Format = Format{
Close: false,
Sep: "",
Prefix: "",
CPrefix: "",
TagFmt: IDString,
TagOpen: "<",
TagClose: ">",
EndTagOpen: "</",
EndTagClose: ">",
AttrSep: " ",
AttrKFmt: IDString,
AttrVFmt: QuoteString,
}