DEV Community

Learning API struggling with Go html/template need advice.

Samuel Fuller on July 02, 2020

I have been working on this for an embarrassingly long amount of time and I feel like I am losing my mind. I will try to explain and be brief and a...
Collapse
 
evanj profile image
Evan Jones

I don't see anything obviously wrong on first look. template#ExecuteTemplate can error out. I would check that error. Wouldn't pass http.ResponseWriter to ExecuteTemplate as well (use a temp &bytes.Buffer{}, then copy to http.ResponseWriter on success -- io.Copy).

When I've hit snags with templating similar to this I've spit everything out, {{ . }}. What's that provide?

Isolate the issue and throw into a repo/gist and I'm happy to take a peak. You might find the issue while doing so. Good luck!

Collapse
 
ohhnate profile image
Samuel Fuller

Hey I appreciate the input and the help! I was able to fix the problem yesterday. The issue was regarding some

{{ . }}

reference on my html file that I didnt do correctly and was so certain it wasn't an issue I didn't include it on my initial post. Everything has went smoothly thus far today. I still feel a bit overwhelmed with templating and everything is starting to turn into a mess. I sorta want to work backward from where I am to get to a point where I fully understand everything. And do things more concisely. But anyways. Thank you very much for the help!