3 ms·
are event handlers possible? neither the Github repo nor the linked page showed an example of a button or form submission.
by floydnoel 2y ago
are event handlers possible? neither the Github repo nor the linked page showed an example of a button or form submission.
- Woshiwuja 2y ago[dead]
- burgerrito 2y agoThis is basically a HTML templating library. It's server side only. Or do you mean event handlers in the HTML attributes?
- tomhallett 2y agoIf you mean “action=/foo” for a “form” tag, there is an “Action” attribute: https://github.com/maragudk/gomponents/blob/main/html/attributes.go#L79 https://github.com/maragudk/gomponents/blob/main/html/attrib...
- markusw 2y agoThe OG event handler. :D
- _heimdall 2y agoIt 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.
- markusw 2y agoYep, this exactly. And the starter kit mentioned is here, for anyone curious: https://github.com/maragudk/gomponents-starter-kit https://github.com/maragudk/gomponents-starter-kit
- markusw 2y agogomponents 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 https://github.com/maragudk/gomponents-htmx