This is what Alex Edwards in his book "Let's Go" does and I am using it.  
He writes it to a buffer and checks for errors.

Enter code here...

Enter code here...func (app *App) render(w http.ResponseWriter, r *http.
Request, name string) {
t := app.cache[name]
buf := new(bytes.Buffer)
tData, err := app.addDefaultData(app.td, r)
if err != nil {
app.serverError(w, err)
}
err = t.Execute(buf, tData)
if err != nil {
app.serverError(w, err)
return
}
buf.WriteTo(w)
}



On Wednesday, May 20, 2020 at 12:40:38 PM UTC-4, Vivi wrote:
>
> I have not thought of a way how to have 2 or multiple files as a separate 
> string to be parsed by API that request for ...string
> The end goal to verify HTML template for error through a function call, is 
> there a better approach?
>
> func checkHTML(str string) {
>         template.ParseFiles(strHTML)
> }
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/11300f3f-1d99-450b-a908-e8c3d523c7fb%40googlegroups.com.

Reply via email to