Replies: 1 comment 1 reply
-
I tend to use The main benefit of There's not much code, it's more of a convenience - https://github.com/a-h/templ/blob/main/handler.go |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was wondering, what would be the best practice in template rendering in http handlers (HandlerFunc) - use Render() on a templ.Component or do a templ.Handler(templ.Component).ServerHTTP()
With Render() there's probably more control over the resulting response, though also the need, at least for my setup with errcheck linter enabled, to check and handle the io.Writer error returned - then as the writer produces an error probably just log that as it's not possible to pass this info currently to the gui consumer (and the more ifs the more I get yelled at by the code checker about cognitive complexity and nesting)
templ.Handler and its ServeHTTP() seems to be intended to be used as handler directly, not within my own handlers, although quite a few projects I checked use this method within HandleFunc
Any insights/thoughts/... on this are appreciated
Thanks
Beta Was this translation helpful? Give feedback.
All reactions