-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbeautify_options.go
198 lines (167 loc) · 5.7 KB
/
beautify_options.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package mjml
type BeautifyBraceStyle string
const (
BeautifyBraceStyleCollapsePreserveInline BeautifyBraceStyle = "collapse-preserve-inline"
BeautifyBraceStyleCollapse BeautifyBraceStyle = "collapse"
BeautifyBraceStyleExpand BeautifyBraceStyle = "expand"
BeautifyBraceStyleEndExpand BeautifyBraceStyle = "end-expand"
BeautifyBraceStyleNone BeautifyBraceStyle = "none"
)
type BeautifyIndentScripts string
const (
BeautifyIndentScriptsKeep BeautifyIndentScripts = "keep"
BeautifyIndentScriptsSeparate BeautifyIndentScripts = "separate"
BeautifyIndentScriptsNormal BeautifyIndentScripts = "normal"
)
type BeautifyWrapAttributes string
const (
BeautifyWrapAttributesAuto BeautifyWrapAttributes = "auto"
BeautifyWrapAttributesForce BeautifyWrapAttributes = "force"
BeautifyWrapAttributesForceAligned BeautifyWrapAttributes = "force-aligned"
BeautifyWrapAttributesForceExpandMultiline BeautifyWrapAttributes = "force-expand-multiline"
BeautifyWrapAttributesAlignedMultiple BeautifyWrapAttributes = "aligned-multiple"
BeautifyWrapAttributesPreserve BeautifyWrapAttributes = "preserve"
BeautifyWrapAttributesPreserveAligned BeautifyWrapAttributes = "preserved-aligned"
)
type BeautifyTemplating string
const (
BeautifyTemplatingAuto BeautifyTemplating = "auto"
BeautifyTemplatingNone BeautifyTemplating = "none"
BeautifyTemplatingDjango BeautifyTemplating = "django"
BeautifyTemplatingERB BeautifyTemplating = "erb"
BeautifyTemplatingHandlebars BeautifyTemplating = "handlebars"
BeautifyTemplatingPHP BeautifyTemplating = "php"
BeautifyTemplatingSmarty BeautifyTemplating = "smarty"
)
// BeautifyOptions is used to construct Beautify options to be passed to the MJML compiler
// Detailed explanations of the options are here: https://github.com/beautify-web/js-beautify#css--html
type BeautifyOptions interface {
IndentSize(uint) BeautifyOptions
IndentChar(string) BeautifyOptions
IndentWithTabs(bool) BeautifyOptions
Eol(string) BeautifyOptions
EndWithNewline(bool) BeautifyOptions
PreserveNewlines(bool) BeautifyOptions
MaxPreserveNewlines(uint) BeautifyOptions
IndentInnerHtml(bool) BeautifyOptions
BraceStyle(BeautifyBraceStyle) BeautifyOptions
IndentScripts(BeautifyIndentScripts) BeautifyOptions
WrapLineLength(uint) BeautifyOptions
WrapAttributes(BeautifyWrapAttributes) BeautifyOptions
WrapAttributesIndentSize(uint) BeautifyOptions
Inline([]string) BeautifyOptions
Unformatted([]string) BeautifyOptions
ContentUnformatted([]string) BeautifyOptions
ExtraLiners([]string) BeautifyOptions
UnformattedContentDelimiter(string) BeautifyOptions
IndentEmptyLines(bool) BeautifyOptions
Templating([]BeautifyTemplating) BeautifyOptions
}
type beautifyOptions struct {
data map[string]interface{}
}
func (o *beautifyOptions) IndentSize(indentSize uint) BeautifyOptions {
ret := *o
ret.data["indent_size"] = indentSize
return &ret
}
func (o *beautifyOptions) IndentChar(character string) BeautifyOptions {
ret := *o
ret.data["indent_char"] = character
return &ret
}
func (o *beautifyOptions) IndentWithTabs(b bool) BeautifyOptions {
ret := *o
ret.data["indent_with_tabs"] = b
return &ret
}
func (o *beautifyOptions) Eol(string string) BeautifyOptions {
ret := *o
ret.data["eol"] = string
return &ret
}
func (o *beautifyOptions) EndWithNewline(b bool) BeautifyOptions {
ret := *o
ret.data["end_with_newline"] = b
return &ret
}
func (o *beautifyOptions) PreserveNewlines(b bool) BeautifyOptions {
ret := *o
ret.data["preserve_newlines"] = b
return &ret
}
func (o *beautifyOptions) MaxPreserveNewlines(max uint) BeautifyOptions {
ret := *o
ret.data["max_preserve_newlines"] = max
return &ret
}
func (o *beautifyOptions) IndentInnerHtml(b bool) BeautifyOptions {
ret := *o
ret.data["indent_inner_html"] = b
return &ret
}
func (o *beautifyOptions) BraceStyle(braceStyle BeautifyBraceStyle) BeautifyOptions {
ret := *o
ret.data["brace_style"] = braceStyle
return &ret
}
func (o *beautifyOptions) IndentScripts(indentScripts BeautifyIndentScripts) BeautifyOptions {
ret := *o
ret.data["indent_scripts"] = indentScripts
return &ret
}
func (o *beautifyOptions) WrapLineLength(lineLength uint) BeautifyOptions {
ret := *o
ret.data["wrap_line_length"] = lineLength
return &ret
}
func (o *beautifyOptions) WrapAttributes(wrapAttributes BeautifyWrapAttributes) BeautifyOptions {
ret := *o
ret.data["wrap_attributes"] = wrapAttributes
return &ret
}
func (o *beautifyOptions) WrapAttributesIndentSize(indentSize uint) BeautifyOptions {
ret := *o
ret.data["wrap_attributes_indent_size"] = indentSize
return &ret
}
func (o *beautifyOptions) Inline(tags []string) BeautifyOptions {
ret := *o
ret.data["inline"] = tags
return &ret
}
func (o *beautifyOptions) Unformatted(tags []string) BeautifyOptions {
ret := *o
ret.data["unformatted"] = tags
return &ret
}
func (o *beautifyOptions) ContentUnformatted(tags []string) BeautifyOptions {
ret := *o
ret.data["content_unformatted"] = tags
return &ret
}
func (o *beautifyOptions) ExtraLiners(tags []string) BeautifyOptions {
ret := *o
ret.data["extra_liners"] = tags
return &ret
}
func (o *beautifyOptions) UnformattedContentDelimiter(string string) BeautifyOptions {
ret := *o
ret.data["unformatted_content_delimiter"] = string
return &ret
}
func (o *beautifyOptions) IndentEmptyLines(b bool) BeautifyOptions {
ret := *o
ret.data["indent_empty_lines"] = b
return &ret
}
func (o *beautifyOptions) Templating(templating []BeautifyTemplating) BeautifyOptions {
ret := *o
ret.data["templating"] = templating
return &ret
}
func NewBeautifyOptions() BeautifyOptions {
return &beautifyOptions{
data: map[string]interface{}{},
}
}