예제 #1
0
파일: tpl.go 프로젝트: hlandau/degoutils
// 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
}
예제 #2
0
func Show(req *http.Request, errorCode int) {
	ShowRW(miscctx.GetResponseWriter(req), req, errorCode)
}