Description
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?