prototyped svg reports
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
2026-08-19 23:19:41 -06:00
parent 00eed86bb2
commit 82efe19ae0
106 changed files with 5450 additions and 46 deletions
+42
View File
@@ -0,0 +1,42 @@
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()
}