htmgo/framework/h/renderables.go

55 lines
807 B
Go
Raw Permalink Normal View History

package h
type AttributeR struct {
Name string
Value string
}
2024-09-30 17:39:48 +00:00
type KeyValue[T any] struct {
Key string
Value T
}
type TextContent struct {
Content string
}
type RawContent struct {
Content string
}
type ChildList struct {
Children []Ren
}
func NewAttribute(name string, value string) *AttributeR {
return &AttributeR{
Name: name,
Value: value,
}
}
func NewRawContent(content string) *RawContent {
return &RawContent{
Content: content,
}
}
func NewTextContent(content string) *TextContent {
return &TextContent{
Content: content,
}
}
func NewChildList(children ...Ren) *ChildList {
2024-09-29 14:45:17 +00:00
cl := &ChildList{
Children: Filter(children, func(item Ren) bool {
return item != nil
}),
}
2024-09-29 14:45:17 +00:00
if len(children) == 0 || children == nil {
cl.Children = make([]Ren, 0)
}
return cl
}