You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some programs expect their users to write templates. One of these programs is docker-gen, and one of its users filed issue #14992 as they found the template language too restrictive for what they were trying to do.
As it happened, docker-gen provided the a template function to let the user do what they wanted (filter a set of structs based on the value of a field, and print something different if no structs with that field set to that specific value are found). That function is documented by the docker-gen README:
where $items $fieldPath $value: Filters an array or slice based on the values of a field path expression $fieldPath. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value. Returns an array of items having that value.
The docker-gen program provides many such functions (see the README for the full list). Some of them are specific to docker-gen's purpose, but many of them are general purpose (such as where above).
Should we add some of these functions (or functions with similar behavior) to the built in set of template functions?
For what it's worth, I got my info about templating from here: https://golang.org/pkg/text/template/
So whereever the actual code is added, it might be helpful if a mention of some sort would be added on that page (e.g. a link to the documentation of that additional package or something)
Some programs expect their users to write templates. One of these programs is
docker-gen
, and one of its users filed issue #14992 as they found the template language too restrictive for what they were trying to do.As it happened,
docker-gen
provided the a template function to let the user do what they wanted (filter a set of structs based on the value of a field, and print something different if no structs with that field set to that specific value are found). That function is documented by thedocker-gen
README:The
docker-gen
program provides many such functions (see the README for the full list). Some of them are specific todocker-gen
's purpose, but many of them are general purpose (such aswhere
above).Should we add some of these functions (or functions with similar behavior) to the built in set of template functions?
cc @robpike @bradfitz @Jonast
The text was updated successfully, but these errors were encountered: