package template
import (
"strings"
)
var attrTypeMap = map [string ]contentType {
"accept" : contentTypePlain ,
"accept-charset" : contentTypeUnsafe ,
"action" : contentTypeURL ,
"alt" : contentTypePlain ,
"archive" : contentTypeURL ,
"async" : contentTypeUnsafe ,
"autocomplete" : contentTypePlain ,
"autofocus" : contentTypePlain ,
"autoplay" : contentTypePlain ,
"background" : contentTypeURL ,
"border" : contentTypePlain ,
"checked" : contentTypePlain ,
"cite" : contentTypeURL ,
"challenge" : contentTypeUnsafe ,
"charset" : contentTypeUnsafe ,
"class" : contentTypePlain ,
"classid" : contentTypeURL ,
"codebase" : contentTypeURL ,
"cols" : contentTypePlain ,
"colspan" : contentTypePlain ,
"content" : contentTypeUnsafe ,
"contenteditable" : contentTypePlain ,
"contextmenu" : contentTypePlain ,
"controls" : contentTypePlain ,
"coords" : contentTypePlain ,
"crossorigin" : contentTypeUnsafe ,
"data" : contentTypeURL ,
"datetime" : contentTypePlain ,
"default" : contentTypePlain ,
"defer" : contentTypeUnsafe ,
"dir" : contentTypePlain ,
"dirname" : contentTypePlain ,
"disabled" : contentTypePlain ,
"draggable" : contentTypePlain ,
"dropzone" : contentTypePlain ,
"enctype" : contentTypeUnsafe ,
"for" : contentTypePlain ,
"form" : contentTypeUnsafe ,
"formaction" : contentTypeURL ,
"formenctype" : contentTypeUnsafe ,
"formmethod" : contentTypeUnsafe ,
"formnovalidate" : contentTypeUnsafe ,
"formtarget" : contentTypePlain ,
"headers" : contentTypePlain ,
"height" : contentTypePlain ,
"hidden" : contentTypePlain ,
"high" : contentTypePlain ,
"href" : contentTypeURL ,
"hreflang" : contentTypePlain ,
"http-equiv" : contentTypeUnsafe ,
"icon" : contentTypeURL ,
"id" : contentTypePlain ,
"ismap" : contentTypePlain ,
"keytype" : contentTypeUnsafe ,
"kind" : contentTypePlain ,
"label" : contentTypePlain ,
"lang" : contentTypePlain ,
"language" : contentTypeUnsafe ,
"list" : contentTypePlain ,
"longdesc" : contentTypeURL ,
"loop" : contentTypePlain ,
"low" : contentTypePlain ,
"manifest" : contentTypeURL ,
"max" : contentTypePlain ,
"maxlength" : contentTypePlain ,
"media" : contentTypePlain ,
"mediagroup" : contentTypePlain ,
"method" : contentTypeUnsafe ,
"min" : contentTypePlain ,
"multiple" : contentTypePlain ,
"name" : contentTypePlain ,
"novalidate" : contentTypeUnsafe ,
"open" : contentTypePlain ,
"optimum" : contentTypePlain ,
"pattern" : contentTypeUnsafe ,
"placeholder" : contentTypePlain ,
"poster" : contentTypeURL ,
"profile" : contentTypeURL ,
"preload" : contentTypePlain ,
"pubdate" : contentTypePlain ,
"radiogroup" : contentTypePlain ,
"readonly" : contentTypePlain ,
"rel" : contentTypeUnsafe ,
"required" : contentTypePlain ,
"reversed" : contentTypePlain ,
"rows" : contentTypePlain ,
"rowspan" : contentTypePlain ,
"sandbox" : contentTypeUnsafe ,
"spellcheck" : contentTypePlain ,
"scope" : contentTypePlain ,
"scoped" : contentTypePlain ,
"seamless" : contentTypePlain ,
"selected" : contentTypePlain ,
"shape" : contentTypePlain ,
"size" : contentTypePlain ,
"sizes" : contentTypePlain ,
"span" : contentTypePlain ,
"src" : contentTypeURL ,
"srcdoc" : contentTypeHTML ,
"srclang" : contentTypePlain ,
"srcset" : contentTypeSrcset ,
"start" : contentTypePlain ,
"step" : contentTypePlain ,
"style" : contentTypeCSS ,
"tabindex" : contentTypePlain ,
"target" : contentTypePlain ,
"title" : contentTypePlain ,
"type" : contentTypeUnsafe ,
"usemap" : contentTypeURL ,
"value" : contentTypeUnsafe ,
"width" : contentTypePlain ,
"wrap" : contentTypePlain ,
"xmlns" : contentTypeURL ,
}
func attrType(name string ) contentType {
if strings .HasPrefix (name , "data-" ) {
name = name [5 :]
} else if prefix , short , ok := strings .Cut (name , ":" ); ok {
if prefix == "xmlns" {
return contentTypeURL
}
name = short
}
if t , ok := attrTypeMap [name ]; ok {
return t
}
if strings .HasPrefix (name , "on" ) {
return contentTypeJS
}
if strings .Contains (name , "src" ) ||
strings .Contains (name , "uri" ) ||
strings .Contains (name , "url" ) {
return contentTypeURL
}
return contentTypePlain
}
The pages are generated with Golds v0.6.9-preview . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .