In-reply-to » What kind of fucking bullshit is this horrible Go template garbage!? What the hell is wrong with my template? https://lyse.isobeef.org/tmp/wtf_test.go.txt I rip it all out and replace it with some other template engine that doesn't suck balls. Holy fuck. What a giant waste of time, every fucking time I deal with this shit. End of rage. :-)

@prologic@twtxt.net I’m coming from the Tornado world, so Tornado templates would be really great. Or Jinja, they’e quite close, although I like Tornado more. It’s been a while, though, that I heavily worked with them.

Looking around I found a few candiates that might be worth looking into. Haven’t tried any of them so far, though. I just looked at their dependencies, syntax and features.

I came across https://git.sr.ht/~dvko/extemplate which I believe is a must if one sticks to the standard library. It adds the extends concept, which is heaps more natural to me instead of of keeping track of the relations and reparsing them manually myself. The template.ParseFS(…) seems to be rather useless I have found. It doesn’t really work all that great. Or I was holding things wrong. I will give extemplate a shot today regardless whether I stick with the default templates. extemplates doesn’t have any other dependencies which is always a big plus in my book.

https://github.com/CloudyKit/jet/blob/master/docs/syntax.md looks fairly useable. It only uses one additional small third-party library which has no dependencies itself.

Zero dependencies for https://github.com/flosch/pongo2, a Django-inspired template engine. This is also close to Jinja templates.

https://github.com/valyala/quicktemplate is interesting as it compiles it into native Go code and claims to be very fast. Adds a bunch of dependencies.

A Jina-inspired template engine, that adds heaps of dependencies: https://github.com/noirbizarre/gonja I guess I have to compare Jinja and Djano before I know which syntax I generally like more. Probably would go with pongo2 over gonja, just of the number of deps. But more investigation is needed.

Another Jinja2 with an even larger number of third party libraries is https://github.com/kluctl/go-jinja2. Seems to work on invoking Python under the hood eventually. So, yeah, most likely not this one.

⤋ Read More