Please check the error on the line that calls template.New. I believe it's reporting failure.
-rob On Sat, Mar 25, 2017 at 9:56 AM, priyank pulumati < pulumati.priy...@gmail.com> wrote: > Sry for little info, template.Base is a constant ("templates/base.html", a > path) and the same for templateName passed from my controller. > But what do i pass in template.New() ? > > On Saturday, March 25, 2017 at 10:17:23 PM UTC+5:30, Yves Junqueira wrote: >> >> Your ParseFiles call has a "templateName" argument in it. The ParseFiles >> function only takes file paths, not template names. >> >> And templates.New takes a template name, not a file path. >> >> Hope this helps. >> >> On Sat, Mar 25, 2017 at 9:14 AM, priyank pulumati <pulumati...@gmail.com> >> wrote: >> >>> hello, >>> im building a go web app and facing an issue with Executing templates >>> with custom functions >>> >>> func CustomTemplateExecute(res http.ResponseWriter, req *http.Request, >>> templateName string, data map[string]interface{}) { >>> // Append common templates and data structs and execute template >>> var funcMap = template.FuncMap{ >>> "humanSize": humanSize, >>> } >>> t, _ := template.New("").Funcs(funcMap).ParseFiles(templates.BASE, >>> templates.NOTIFICATIONS, templates.TICKER, templateName) >>> if len(data) == 0 { >>> data = make(map[string]interface{}) >>> data["user"], _ = store.GetUser(context.Get(req, "userid").(string)) >>> data["isadmin"] = store.IsAdmin(context.Get(req, "userid").(string)) >>> } else { >>> data["user"], _ = store.GetUser(context.Get(req, "userid").(string)) >>> data["isadmin"] = store.IsAdmin(context.Get(req, "userid").(string)) >>> } >>> t.Execute(res, data) >>> } >>> >>> func humanSize() string { >>> return "Hello" >>> } >>> >>> I get template is empty error, i have tried giving a name to >>> template.new and its the same error. >>> Any help is appreciated, thank you ! >>> >>> -- >>> 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...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.