Esempio n. 1
0
// Try to show the template with the given name and args. Return an error on failure.
//
// The error might be ErrNotFound.
func Show(req *http.Request, name string, args map[string]interface{}) error {
	tpl, ok := templates[name]
	if !ok {
		return ErrNotFound
	}

	if args == nil {
		args = map[string]interface{}{}
	}

	if GetContextFunc != nil {
		args["c"] = GetContextFunc(req)
	}

	rw := miscctx.GetResponseWriter(req)
	err := tpl.ExecuteWriter(args, rw)
	if err != nil {
		return err
	}

	miscctx.SetCanOutputTime(req)
	return nil
}
Esempio n. 2
0
func Show(req *http.Request, errorCode int) {
	ShowRW(miscctx.GetResponseWriter(req), req, errorCode)
}