-
-
Notifications
You must be signed in to change notification settings - Fork 579
Go Template panic can't install method/function "contentFor" with 0 results
#1767
Comments
Those helpers are written for plush, and don’t support Go templates as Go’s templating system is capable of such feats of strength. If you use Go templates you won’t get any of the plush templates. This is expected behavior. |
https://gobuffalo.io/en/docs/helpers The documention states this. |
The issue is not that I want to use the helpers, the issue is that I can't use go templates, because as far as I can tell by default it's attempting to inject the helpers. buffalo/render/template_engine.go Line 20 in 23ce3e3
Did I miss something in the document where I need to explicitly remove the helpers in order to use go templates? |
That is a different issue. The ticket reads the other way. I’ll reopen because it probably shouldn’t do that. |
@tw-maustin As I'm not typically using go templates with buffalo I have a question for you, do you use any of the helpers when you use Go templates or you don't ? @markbates would the solution for this one avoid passing the buffalo helpers to Go templates or just removing |
Honestly, I am also using plush templates now. From what I remember reading in the docs at that time, I would not have expected any of the helpers to work with Go Templates. |
Solved in v0.16.8 |
Description
When using Go Templates Engine in a default build. there is a panic related to the "contentFor" helper.
Steps to Reproduce the Problem
Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the
curl
command you used, that sort of thing.buffalo new tmpl
buffalo generate action foo index
templates/foo/index.plush.html
totemplates/foo/index.tmpl
return c.Render(200, r.HTML("foo/index.tmpl"))
Expected Behavior
I expected this would render the foo/index.tmpl contents via the default go template renderer
Foo#Index
Actual Behavior
500 Error
can't install method/function "contentFor" with 0 results
In the happiest of happy places what should have happened?
Template should render.
Note
I further tracked the issue and discovered that if I remove "contentFor" from the helpers map in GoTemplateEngine
delete(helpers,"contentFor")
The template will then render properly. Obviously this is not a real fix, but I thought the information might help track the actual problem.Info
The text was updated successfully, but these errors were encountered: