github.com/gofiber/pug@v1.0.1/config.go (about) 1 package jade 2 3 //go:generate stringer -type=itemType,NodeType -trimprefix=item -output=config_string.go 4 5 var TabSize = 4 6 7 var ( 8 golang_mode = false 9 tag__bgn = "<%s%s>" 10 tag__end = "</%s>" 11 tag__void = "<%s%s/>" 12 tag__arg_esc = ` %s="{{ print %s }}"` 13 tag__arg_une = ` %s="{{ print %s }}"` 14 tag__arg_str = ` %s="%s"` 15 tag__arg_add = `%s " " %s` 16 tag__arg_bgn = "" 17 tag__arg_end = "" 18 19 cond__if = "{{ if %s }}" 20 cond__unless = "{{ if not %s }}" 21 cond__case = "{{/* switch %s */}}" 22 cond__while = "{{ range %s }}" 23 cond__for = "{{/* %s, %s */}}{{ range %s }}" 24 cond__end = "{{ end }}" 25 26 cond__for_if = "{{ if gt len %s 0 }}{{/* %s, %s */}}{{ range %s }}" 27 code__for_else = "{{ end }}{{ else }}" 28 29 code__longcode = "{{/* %s */}}" 30 code__buffered = "{{ %s }}" 31 code__unescaped = "{{ %s }}" 32 code__else = "{{ else }}" 33 code__else_if = "{{ else if %s }}" 34 code__case_when = "{{/* case %s: */}}" 35 code__case_def = "{{/* default: */}}" 36 code__mix_block = "{{/* block */}}" 37 38 text__str = "%s" 39 text__comment = "<!--%s -->" 40 41 mixin__bgn = "\n%s" 42 mixin__end = "" 43 mixin__var_bgn = "" 44 mixin__var = "{{ $%s := %s }}" 45 mixin__var_rest = "{{ $%s := %#v }}" 46 mixin__var_end = "\n" 47 mixin__var_block_bgn = "" 48 mixin__var_block = "" 49 mixin__var_block_end = "" 50 ) 51 52 type Cfg struct { 53 GolangMode bool 54 TagBgn string 55 TagEnd string 56 TagVoid string 57 TagArgEsc string 58 TagArgUne string 59 TagArgStr string 60 TagArgAdd string 61 TagArgBgn string 62 TagArgEnd string 63 64 CondIf string 65 CondUnless string 66 CondCase string 67 CondWhile string 68 CondFor string 69 CondEnd string 70 CondForIf string 71 72 CodeForElse string 73 CodeLongcode string 74 CodeBuffered string 75 CodeUnescaped string 76 CodeElse string 77 CodeElseIf string 78 CodeCaseWhen string 79 CodeCaseDef string 80 CodeMixBlock string 81 82 TextStr string 83 TextComment string 84 85 MixinBgn string 86 MixinEnd string 87 MixinVarBgn string 88 MixinVar string 89 MixinVarRest string 90 MixinVarEnd string 91 MixinVarBlockBgn string 92 MixinVarBlock string 93 MixinVarBlockEnd string 94 } 95 96 func Config(c Cfg) { 97 golang_mode = c.GolangMode 98 if c.TagBgn != "" { 99 tag__bgn = c.TagBgn 100 } 101 if c.TagEnd != "" { 102 tag__end = c.TagEnd 103 } 104 if c.TagVoid != "" { 105 tag__void = c.TagVoid 106 } 107 if c.TagArgEsc != "" { 108 tag__arg_esc = c.TagArgEsc 109 } 110 if c.TagArgUne != "" { 111 tag__arg_une = c.TagArgUne 112 } 113 if c.TagArgStr != "" { 114 tag__arg_str = c.TagArgStr 115 } 116 if c.TagArgAdd != "" { 117 tag__arg_add = c.TagArgAdd 118 } 119 if c.TagArgBgn != "" { 120 tag__arg_bgn = c.TagArgBgn 121 } 122 if c.TagArgEnd != "" { 123 tag__arg_end = c.TagArgEnd 124 } 125 if c.CondIf != "" { 126 cond__if = c.CondIf 127 } 128 if c.CondUnless != "" { 129 cond__unless = c.CondUnless 130 } 131 if c.CondCase != "" { 132 cond__case = c.CondCase 133 } 134 if c.CondWhile != "" { 135 cond__while = c.CondWhile 136 } 137 if c.CondFor != "" { 138 cond__for = c.CondFor 139 } 140 if c.CondEnd != "" { 141 cond__end = c.CondEnd 142 } 143 if c.CondForIf != "" { 144 cond__for_if = c.CondForIf 145 } 146 if c.CodeForElse != "" { 147 code__for_else = c.CodeForElse 148 } 149 if c.CodeLongcode != "" { 150 code__longcode = c.CodeLongcode 151 } 152 if c.CodeBuffered != "" { 153 code__buffered = c.CodeBuffered 154 } 155 if c.CodeUnescaped != "" { 156 code__unescaped = c.CodeUnescaped 157 } 158 if c.CodeElse != "" { 159 code__else = c.CodeElse 160 } 161 if c.CodeElseIf != "" { 162 code__else_if = c.CodeElseIf 163 } 164 if c.CodeCaseWhen != "" { 165 code__case_when = c.CodeCaseWhen 166 } 167 if c.CodeCaseDef != "" { 168 code__case_def = c.CodeCaseDef 169 } 170 if c.CodeMixBlock != "" { 171 code__mix_block = c.CodeMixBlock 172 } 173 if c.TextStr != "" { 174 text__str = c.TextStr 175 } 176 if c.TextComment != "" { 177 text__comment = c.TextComment 178 } 179 if c.MixinBgn != "" { 180 mixin__bgn = c.MixinBgn 181 } 182 if c.MixinEnd != "" { 183 mixin__end = c.MixinEnd 184 } 185 if c.MixinVarBgn != "" { 186 mixin__var_bgn = c.MixinVarBgn 187 } 188 if c.MixinVar != "" { 189 mixin__var = c.MixinVar 190 } 191 if c.MixinVarRest != "" { 192 mixin__var_rest = c.MixinVarRest 193 } 194 if c.MixinVarEnd != "" { 195 mixin__var_end = c.MixinVarEnd 196 } 197 if c.MixinVarBlockBgn != "" { 198 mixin__var_block_bgn = c.MixinVarBlockBgn 199 } 200 if c.MixinVarBlock != "" { 201 mixin__var_block = c.MixinVarBlock 202 } 203 if c.MixinVarBlockEnd != "" { 204 mixin__var_block_end = c.MixinVarBlockEnd 205 } 206 } 207 208 type Out struct { 209 Name, Args, Import string 210 } 211 212 var Go Out 213 214 func ConfigOtputPHP() {} 215 216 type itemType int8 217 218 const ( 219 itemError itemType = iota // error occurred; value is text of error 220 itemEOF 221 222 itemEndL 223 itemIdent 224 itemEmptyLine // empty line 225 226 itemText // plain text 227 228 itemComment // html comment 229 itemHTMLTag // html <tag> 230 itemDoctype // Doctype tag 231 232 itemDiv // html div for . or # 233 itemTag // html tag 234 itemTagInline // inline tags 235 itemTagEnd // for <tag /> 236 itemTagVoid // self-closing tags 237 itemTagVoidInline // inline + self-closing tags 238 239 itemID // id attribute 240 itemClass // class attribute 241 242 itemAttrStart 243 itemAttrEnd 244 itemAttr 245 itemAttrSpace 246 itemAttrComma 247 itemAttrEqual 248 itemAttrEqualUn 249 250 itemFilter 251 itemFilterSubf 252 itemFilterArgs 253 itemFilterText 254 255 // itemKeyword // used only to delimit the keywords 256 257 itemInclude 258 itemExtends 259 itemBlock 260 itemBlockAppend 261 itemBlockPrepend 262 itemMixin 263 itemMixinCall 264 itemMixinBlock 265 266 itemCode 267 itemCodeBuffered 268 itemCodeUnescaped 269 270 itemIf 271 itemElse 272 itemElseIf 273 itemUnless 274 275 itemEach 276 itemWhile 277 itemFor 278 itemForIfNotContain 279 itemForElse 280 281 itemCase 282 itemCaseWhen 283 itemCaseDefault 284 ) 285 286 var key = map[string]itemType{ 287 "include": itemInclude, 288 "extends": itemExtends, 289 "block": itemBlock, 290 "append": itemBlockAppend, 291 "prepend": itemBlockPrepend, 292 "mixin": itemMixin, 293 294 "if": itemIf, 295 "else": itemElse, 296 "unless": itemUnless, 297 "for": itemFor, 298 "each": itemEach, 299 "while": itemWhile, 300 "case": itemCase, 301 "when": itemCaseWhen, 302 "default": itemCaseDefault, 303 304 "doctype": itemDoctype, 305 306 "a": itemTagInline, 307 "abbr": itemTagInline, 308 "acronym": itemTagInline, 309 "b": itemTagInline, 310 "code": itemTagInline, 311 "em": itemTagInline, 312 "font": itemTagInline, 313 "i": itemTagInline, 314 "ins": itemTagInline, 315 "kbd": itemTagInline, 316 "map": itemTagInline, 317 "samp": itemTagInline, 318 "small": itemTagInline, 319 "span": itemTagInline, 320 "strong": itemTagInline, 321 "sub": itemTagInline, 322 "sup": itemTagInline, 323 324 "area": itemTagVoid, 325 "base": itemTagVoid, 326 "col": itemTagVoid, 327 "command": itemTagVoid, 328 "embed": itemTagVoid, 329 "hr": itemTagVoid, 330 "input": itemTagVoid, 331 "keygen": itemTagVoid, 332 "link": itemTagVoid, 333 "meta": itemTagVoid, 334 "param": itemTagVoid, 335 "source": itemTagVoid, 336 "track": itemTagVoid, 337 "wbr": itemTagVoid, 338 339 "br": itemTagVoidInline, 340 "img": itemTagVoidInline, 341 } 342 343 // NodeType identifies the type of a parse tree node. 344 type NodeType int 345 346 // Type returns itself and provides an easy default implementation 347 // for embedding in a Node. Embedded in all non-trivial Nodes. 348 func (t NodeType) Type() NodeType { 349 return t 350 } 351 352 const ( 353 NodeText NodeType = iota 354 NodeList 355 NodeTag 356 NodeCode 357 NodeCond 358 NodeString 359 NodeDoctype 360 NodeMixin 361 NodeBlock 362 )