It’s very different. It’s a meta language that compiles to Go. It ensures correct syntax at compile time, and makes it much easier to treat parts of views as real values instead of bits of text. Much better composition, at the cost of a much more complex build
system.
I think this answered my only question: how the heck is he just writing HTML inside of Go, as far as I know, Go doesn't have any metaprogramming to that extent, and I doubt Go ever will.
Last I checked Gos built in templating system lacked one feature that I see as very basic and that IMO makes it hard to organize code and templates logically:
To very common things to do when templating is
- to include a sub-template (e.g. the article template includes the sidebar template)
- to specify that the template I work with and probably others should be rendered inside a slot in a containing template (e.g. the article template should be rendered into the general root template that contains the public menu but the admin pages should render in another root template)
Last I checked only the first of these use cases were supported.
You're right. But this only means that it won't be possible that you use the same template for different slots. Personally, I don't remember I ever needed that. Actually, most template engines I know work this way (https://twig.symfony.com/doc/2.x/templates.html#template-inh..., "{% block content %}").
But still, it's easy to archieve that by just creating another sub template.
So your first template file is the layout, the second one contains the main block definition, and that definition you just include another sub template which can be reused elsewhere.
That’s what I like about Go. The platform is prescriptive, but in all the right places. For things like this, Go leaves the abstraction building to you, if you need it.
https://pkg.go.dev/html/template
Which is based on top of text/template.