Templ: A language for writing HTML user interfaces in Go

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • LearnThisRepo.com - Learn 300+ open source libraries for free using AI.
  • WorkOS - The modern API for authentication & user identity.
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • gomponents

    View components in pure Go, that render to HTML 5.

    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. :)

  • templ

    A language for writing HTML user interfaces in Go.

  • LearnThisRepo.com

    Learn 300+ open source libraries for free using AI. LearnThisRepo lets you learn 300+ open source repos including Postgres, Langchain, VS Code, and more by chatting with them using AI!

  • htmlgo

    A library for writing type-safe HTML in Golang

    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

  • element

    Native Go (golang) HTML generator - template eliminator (by rohanthewiz)

    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

  • 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

    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

  • jte

    Secure and speedy templates for Java and Kotlin.

    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.

  • sprig

    Useful template functions for Go templates.

    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.

  • WorkOS

    The modern API for authentication & user identity. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • maud

    :pencil: Compile-time HTML templates for Rust

    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).

  • gomponents-htmx

    HTMX attributes and helpers for gomponents.

  • service

    A template for Go services. (by maragudk)

    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.

  • golang-layout-tpl-example

    A small example how to implement page templates using the same layout in Go. Just for education purposes.

    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.

  • webxx

    Declarative, composable, concise & fast HTML & CSS components in C++

    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

  • tal

    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?

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts