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

add support for Template functions #93

Closed
ccamel opened this issue Jun 8, 2023 · 3 comments · Fixed by #98
Closed

add support for Template functions #93

ccamel opened this issue Jun 8, 2023 · 3 comments · Fixed by #98

Comments

@ccamel
Copy link
Contributor

ccamel commented Jun 8, 2023

As far as I can see, it is not possible to define additional Template functions. For example, the following code defines some functions:

		if renderer.tmpl == nil {
			tmpl := template.New(name)
			tmpl.Funcs(map[string]interface{}{
				"add": func(n1, n2 int) int {
					return n1 + n2
				},
 ...

but it would be great to be able to add others (such as the functions provided by Sprig for instance), when creating a new renderer (NewRenderer).

@ccamel ccamel changed the title a add support for Template functions Jun 8, 2023
@ccamel
Copy link
Contributor Author

ccamel commented Jun 9, 2023

I can submit a PR if it can help. 😌
Just let me know.

@princjef
Copy link
Owner

I've put together a small change that adds a WithTemplateFunc option to the renderer. Let me know if that solves your issue

@ccamel
Copy link
Contributor Author

ccamel commented Jun 12, 2023

@princjef Great! That's perfect. Thanks. 👍

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

Successfully merging a pull request may close this issue.

2 participants