|
|
|
|
|
by eknkc
3416 days ago
|
|
While I agree in theory, I can't stand that in practice :). For example, let's say I want to show a usage stat, I'd pass something like { usage: 100, limit: 1000 } to the template engine. Let's say I want to add a percentage. I believe the calculation should be on the presentation layer. That's how I decide to present this particular data. Go templates lack that functionality for no good reason. And if I'm gonna calculate that on the backend, why exactly am I using a template engine? I'd concatenate strings. |
|
You will quickly find if you use this that it's in fact worse: go templates have LISP syntax. A set of atoms, specified in reverse Polish notation, doing function application to all but the first atom.
[1] https://golang.org/pkg/text/template/#Template.Funcs
[2] https://github.com/Masterminds/sprig