Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capability to select specific functions for use #433

Open
jtmcg opened this issue Feb 20, 2025 · 0 comments
Open

Capability to select specific functions for use #433

jtmcg opened this issue Feb 20, 2025 · 0 comments

Comments

@jtmcg
Copy link

jtmcg commented Feb 20, 2025

Problem Statement

There are, impressively, around 250 functions for templating included in this package. We would be interested in a way to cherry-pick which functions we include when using this in our own project to reduce the surface area we wish to support. There is already a helper that trims out the non-hermetic functions, HermeticTxtFuncMap, but I'd be interested in one that returns functions or families of functions provided by the consumer.

Potential API

Here's one way this might be achieved, leveraging a design similar to the HermeticTxtFuncMap:

func CustomFuncMap(funcs []string) {
    r := TxtFuncMap()
    for name, _ := range genericMap {
        if !slices.contains(funcs, name) {
            delete(r, name)
        }
    }
    return r
}

It may also be useful to surface an exported enum of supported functions to support this.

Alternatively, the genericMap could be exported, allowing consumers to manipulate the map and build their own template.FuncMap{} from that starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant