-
Notifications
You must be signed in to change notification settings - Fork 8k
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
LoadHTMLTemplates not work! #145
Comments
I am having this same issue. Apologies in advance. I have forgotten how to do pretty github markdown. Just to test, I put fmt.Println(os.Getwd()) in the handler and it returned the base path where the server is run (/Users/erin/codebase/bangorang, no trailing /). So I tried various permutations of ./ and /full/path/to/file, and I see Error #1: html/template: "/Users/erin/codebase/bangorang/src/github.com/mycode/myproject/templates/test.tmpl" is undefined I copied the file test.tmpl into /Users/erin/bangorang and sure enough, it worked. This prompted me to start digging around in html/template -- I think the problem is around here: http://golang.org/src/pkg/html/template/template.go?s=9766:9835#L324 More investigation required. Just wanted to make noise. |
If you look at this line: https://github.com/gin-gonic/gin/blob/develop/render/render.go#L122 This assumes that the file path is absolute. However, if I try to give a complete path as a string to this, I see
See http://golang.org/src/html/template/template.go?s=9766:9835#L98 The relevant bits of my code are here. I can create a template object and print the HTML (I was trying to figure out some way to just massage it into the server response, but I'm not there yet): https://gist.github.com/boboTjones/cfce4394a4bc246a33e2 If I run the binary from the template directory, using the command below, the server finds the template and serves the correct response.
Which is what I'm going to do, going forward, assuming this is how gin-gonic is meant to work. |
hi!
here is my code.
here is GetMemberByNick():
here is my project
but,I cannot get the template("/member/:nick" and "/html")
can you help? thanks.
The text was updated successfully, but these errors were encountered: