←back to thread

49 points markusw | 6 comments | | HN request time: 0.994s | source | bottom

Hey everyone! I just released v1.0.0 of gomponents last week. It's an HTML component builder in pure Go, with a DSL-like HTML syntax. It's been 4 years in the making, and makes it really easy to build HTML in your web apps.
1. floydnoel ◴[] No.41852638[source]
are event handlers possible? neither the Github repo nor the linked page showed an example of a button or form submission.
replies(5): >>41856116 #>>41875243 #>>41875298 #>>41876441 #>>41876492 #
2. burgerrito ◴[] No.41875243[source]
This is basically a HTML templating library. It's server side only. Or do you mean event handlers in the HTML attributes?
3. tomhallett ◴[] No.41875298[source]
If you mean “action=/foo” for a “form” tag, there is an “Action” attribute: https://github.com/maragudk/gomponents/blob/main/html/attrib...
4. _heimdall ◴[] No.41876441[source]
It looks like this is focused on server rendering HTML, no client-side runtime or anything like that.

I don't see any used of a `Script()` function or similar in the example apps, though you could always chunk some JS in a public directory and link it in the HTML.

They do have a starter example that uses HTMX. That'd be my go-to as well for a tool that's sticking with server rendering HTML.

replies(1): >>41876496 #
5. markusw ◴[] No.41876492[source]
gomponents is just a glorified string builder, so it's more or less like writing HTML in Go that gets output from the server. So you put event handlers on your elements like you normally would, write scripts and include JS like you normally would, etc.

That said, there's gomponents-htmx [0] for easy integration with HTMX.

[0]: https://github.com/maragudk/gomponents-htmx

6. markusw ◴[] No.41876496[source]
Yep, this exactly. And the starter kit mentioned is here, for anyone curious: https://github.com/maragudk/gomponents-starter-kit