Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
quicktemplate
Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
golang-layout-tpl-example
A small example how to implement page templates using the same layout in Go. Just for education purposes.
I'm really happy you like it. :) And thank you for your comment, I really appreciate newcomer viewpoints especially.
Have a look at the `Classes` helper component already available: https://github.com/maragudk/gomponents/blob/main/components/...
Yeah, I'm not a total fan of the runtime panics, but it was a tradeoff where I chose in favour of API simplicity and readability. In practice, it works out well, because you catch any typos at development time.
I've had elements and attributes in separate packages before, but then you can't dot-import both packages and not have name clashes, and have to either prefix elements or attributes with the package name, which makes the code much less readable. Again, a tradeoff. :)
Here are a couple:
https://github.com/julvo/htmlgo
https://github.com/rohanthewiz/element
I'm sure there are many more.
The thing about these is that performance is often not as good as when using templates, especially when the templates are compiled to native code. Quicktemplate [1] is still the leader here IMO, and I don't think the OP project brings much that couldn't be done pretty easily with QT.
[1] https://github.com/valyala/quicktemplate
Here are a couple:
https://github.com/julvo/htmlgo
https://github.com/rohanthewiz/element
I'm sure there are many more.
The thing about these is that performance is often not as good as when using templates, especially when the templates are compiled to native code. Quicktemplate [1] is still the leader here IMO, and I don't think the OP project brings much that couldn't be done pretty easily with QT.
[1] https://github.com/valyala/quicktemplate
Here are a couple:
https://github.com/julvo/htmlgo
https://github.com/rohanthewiz/element
I'm sure there are many more.
The thing about these is that performance is often not as good as when using templates, especially when the templates are compiled to native code. Quicktemplate [1] is still the leader here IMO, and I don't think the OP project brings much that couldn't be done pretty easily with QT.
[1] https://github.com/valyala/quicktemplate
For java/Kotlin, we are using JTE (https://jte.gg/#getting-started), pretty nice build tooling and IDE support to generate pre-compiled templates without additional code generation steps.
Standard Go templating seems really lacking if you come from something like Jinja. Even with libraries like https://masterminds.github.io/sprig/ (used e.g. for Helm templating) it feels hard to use.
I would like to mention maud in this context:
https://github.com/lambda-fairy/maud
It is refreshingly different from other Rust templating libraries. It uses a proc-macro that compiles your HTML into Rust code. I also happen to use it in conjunction with HTMX and it works very well for me (at least in small projects).
I've got my own super simple service template that I use internally for this: https://github.com/maragudk/service . I don't think I've added HTMX here (because I add it when needed), but it has auth and is totally classic in its setup.
https://github.com/ckilb/golang-layout-tpl-example
I don't like Go's template engine too much, I find it a bit cumbersome in many cases. But it's quite capable.
I believe I recently built something to do exactly what you're describing for HTML, though it's C++ (but maybe a useful basis for a rust version - I don't know).
https://github.com/rthrfrd/webxx
Here is an example of a old technology
TAL -Template Attribute Language
https://en.m.wikipedia.org/wiki/Template_Attribute_Language
which happens to have an (also old) implementation i Go https://github.com/owlfish/tal
I wonder what opinion HN has on this type of templating language?