-
Notifications
You must be signed in to change notification settings - Fork 43
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
Handle passing functions to templates? #2
Comments
I'm also trying to figure out how to get this working. No matter what I do I end up getting an error that the function is not defined. |
My guess is that the randerer treats each comment without leading . as function. This really is an issue, since it interferes with 3rd party stuff including {{tobereplaced}} stuff like dropbox for example. |
Any updates? |
There is two variants how to add Funcs:
AddFromFilesFuncs:
AddFromStringsFuncs:
|
How does any of those methods make the registered functions available within the (HTML) templates, @sergolius? |
@asbjornu tmpl := template.New(name).Funcs(funcMap) |
@sergolius, ah, I see. I managed to get this to work: r := multitemplate.NewRenderer()
r.AddFromFilesFuncs("entry", template.FuncMap{
"my_func": func() string {
return "xyz"
},
}, "views/base.html", "views/entry.html") I am now able to use |
I know it's possible to pass helper functions to normal
html/template
, but is it possible with this wrapper? If not, it would be cool to have it.Thanks!
The text was updated successfully, but these errors were encountered: