-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Export Funcs function to help enable usage of gomplate as library #372
Export Funcs function to help enable usage of gomplate as library #372
Conversation
@dcwangmit01 I wonder if all you need is to export |
@hairyhenderson Gosh darn I think you're right. I'll give it a go, and update this PR. |
You should be good to go with: diff --git a/funcs.go b/funcs.go
index 7d8fd3a..e8dd76f 100644
--- a/funcs.go
+++ b/funcs.go
@@ -7,8 +7,8 @@ import (
"github.com/hairyhenderson/gomplate/funcs"
)
-// initFuncs - The function mappings are defined here!
-func initFuncs(d *data.Data) template.FuncMap {
+// Funcs - The function mappings are defined here!
+func Funcs(d *data.Data) template.FuncMap {
f := template.FuncMap{}
funcs.AddDataFuncs(f, d)
funcs.AWSFuncs(f)
diff --git a/gomplate.go b/gomplate.go
index 11a8ae8..bca66f7 100644
--- a/gomplate.go
+++ b/gomplate.go
@@ -70,7 +70,7 @@ func newGomplate(d *data.Data, leftDelim, rightDelim string) *gomplate {
return &gomplate{
leftDelim: leftDelim,
rightDelim: rightDelim,
- funcMap: initFuncs(d),
+ funcMap: Funcs(d),
}
} Note that I changed the name from |
* Exported the `Funcs` function by upcasing first letter * Demo program found at: https://gist.github.com/dcwangmit01/e9e58dd123e0a8eb48c2f4e8ffa16d5a
2853f1d
to
fa4a51c
Compare
@hairyhenderson Your changed worked perfectly. I've updated this PR with it 😅 , as well as the demo code in the gist. |
Thanks for this, @dcwangmit01 - hope this is useful to you, and I'm sure it'll be useful to others 🙂 |
Thanks for all the help @hairyhenderson, and the quick response. Makes contributing to this project a no-brainer. |
🙇 |
Fixes #371
https://gist.github.com/dcwangmit01/e9e58dd123e0a8eb48c2f4e8ffa16d5a