package svg import ( "bytes" "fmt" "io" "strings" ) type ( // VoidElement is like Element but for void elements VoidElement[T Tag, A Attribute] struct { Attributes []A } ) func (e *VoidElement[T, A]) Attr(as ...A) *VoidElement[T, A] { e.Attributes = append(e.Attributes, as...) return e } func (e VoidElement[T, A]) GetMarkup() string { attrs := make([]string, len(e.Attributes)) for i, a := range e.Attributes { attrs[i] = PrintAttribute(a) } return fmt.Sprintf( `<%s %s/>`, e.PrintTag(), strings.Join(attrs, " "), ) } func (e VoidElement[T, A]) GetMarkupReader() io.Reader { return bytes.NewReader([]byte(e.GetMarkup())) } func (e VoidElement[T, _]) PrintTag() string { var t T return t.PrintTag() }