make syntax less verbose#132
Conversation
bjartek
commented
Mar 28, 2024
- make attrs.Props a Node
- when parsing new element check if first is props and if it is use it if else empty props.
- some builders are now not 100% correct like TextArea can take any Node, this can be fixed though with some simple guards inside that one to allow only 1 textNode and props.
- fixed tests to remove nil
|
if you want to send in more Props here you could even allow merging them all in newElement. |
|
or you could even create a method to generate a single Prop and write code like
|
|
@bjartek If you are looking for that This is a great library, as is the other. There are pros and cons to each. |
|
@bjartek, I'm intrigued by removing the content := elem.Div(
elem.H1(nil, elem.Text("Hello, Elem!")),
attrs.Props{
attrs.ID: "container",
attrs.Class: "my-class",
},
elem.H2(nil, elem.Text("Subheading")),
elem.P(nil, elem.Text("This is a paragraph.")),
)I guess technically, this syntax still works, but I'm curious if it feels strange. Also, I'm wondering if this constitutes a breaking change. Moving some functions or attributes to an options subpackage might be. Regarding the |