Replies: 3 comments 4 replies
-
In terms of getting the tools to work together. To use a gomponent in templ requires a couple of lines of code to adapt it. type Gomponent interface {
Render(w io.Writer) error
}
func ToTempl(g Gomponent) templ.Component {
func templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
return g.Render(w)
})
} To go the other way requires a couple of extra lines.
Would be cool if they interoperated directly.
Yeah, well, you know, that's just, like, your opinion, man. 😁 |
Beta Was this translation helpful? Give feedback.
-
It would be nice to publish some performance figure. I haven't done anyhting quantitative, but I see a drastic performance improvement in templ over html/template. Also, I did not go into this yet, the templ-solution allows for a incremental (call it streaming) feed of html to the client-browser. I don't think either gomponent or html/template will ever be able to do this as creating the html-content is seperate from rendering it. I will do this some time, as my html-pages contain lots of database-fetched sensor-data. The third thing you might want to address is the language cardinality. For html/template one needs to learn a new language. For Gomponent and templ one does not. |
Beta Was this translation helpful? Give feedback.
-
and one more with regards to differences: both gomponent and templ need balanced html-tags within a code-block. html/template doesnt require that as it is mainly language-agnostic. In some situations, it is more effective to have opening and closing html-elements in their own code-blocks. This is only possible, withing non-raw context, in html/template. I find that very confusing, as there is only a hygienic argument for balanced elements, not a necessary one. |
Beta Was this translation helpful? Give feedback.
-
Hi Adrian,
I'm writing an article about Go templating, about Gomponents vs Templ and I wanted to make sure I have a state-of-the-art article about your library.
Is it possible to read it and tell me if I get your library wrong somewhere? Of course, I've sent the article to Gomponents team for proofreading too.
https://nuage.quimerch.com/-/ewen/articles/templ-vs-gomponents
Thanks again for your lib ❤️
Beta Was this translation helpful? Give feedback.
All reactions