4 ms·
I love go templates for this sort of thing, but obviously only works if you’re using golang
by jonfw 4y ago
I love go templates for this sort of thing, but obviously only works if you’re using golang
- mdaniel 4y agoThe discoverability of golang templates is terrible, IMHO, since it's missing a "dir(locals())" equivalent and every execution environment gets to make its own rules about what pipelines/functions are exposed Look at helm as an example: https://helm.sh/docs/chart_template_guide/function_list/ https://helm.sh/docs/chart_template_guide/function_list/ is some of them, https://helm.sh/docs/chart_template_guide/accessing_files/#path-helpers https://helm.sh/docs/chart_template_guide/accessing_files/#p... are some others, but they also glued in some version of https://masterminds.github.io/sprig/ https://masterminds.github.io/sprig/ So, short of (a) knowing that's the case (b) having 3+ bookmarks in your favorite browser to refer to those reference pages, how would anyone know what pipelines are available? Separately, I dooooo nooooooot understand why every joker has to invent their own new thing when we have like 50 or so templating languages already. Golang may be an outlier in that competition due to the Google Promotion Packet Effect(tm) but how they came up with `{{ range }}{{ end }}` as sane syntax is some true facepalm, to say nothing of the same landmine that ansible stepped on by not switching jinja2's default characters: `{{` is not _yaml safe_
- eviks 4y agowha's the best of the 50 in your opinion?
- verdverm 4y agoown-project plug: https://docs.hofstadter.io https://docs.hofstadter.io
- jonfw 4y agoHelm does a poor job of documenting their functions, and when you use helm, you're not really using go templates, you're using helm's wrapper around go templates. If you use go templates directly- it's very obvious what functions are available, there's the default ones from the Go template package, and there's whatever you pass explicitly. The go template package is very small and well documented. What I love about Go templates, is that I can pass any function I want, using good old Go code (meaning I can use SDKs and whatever else). This is really powerful- we're able to have functions that go out to APIs and return data and it's very easy to manage
- mdaniel 4y ago> helm, you're not really using go templates, you're using helm's wrapper around go templates. Well, that's a tautology when having any contact with golang templates outside of quite literally just importing "text/template" and good luck, as your subsequent comment somehow says and yet misses the point. I draw one's attention to the sibling comment of yet another golang templating gizmo that injects its own cutesy functions with completely random naming into the evaluation namespace