Merge pull request #448 from movsb/fix-attribute-string

make RenderAttributes() accept both []byte and string
This commit is contained in:
Yusuke Inuzuka 2024-04-03 18:46:06 +09:00 committed by GitHub
commit c15e394c27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -786,7 +786,14 @@ func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)
_, _ = w.Write(attr.Name) _, _ = w.Write(attr.Name)
_, _ = w.WriteString(`="`) _, _ = w.WriteString(`="`)
// TODO: convert numeric values to strings // TODO: convert numeric values to strings
_, _ = w.Write(util.EscapeHTML(attr.Value.([]byte))) var value []byte
switch typed := attr.Value.(type) {
case []byte:
value = typed
case string:
value = util.StringToReadOnlyBytes(typed)
}
_, _ = w.Write(util.EscapeHTML(value))
_ = w.WriteByte('"') _ = w.WriteByte('"')
} }
} }