improve build-in varables for view of ghttp
@@ -74,13 +74,16 @@ func (r *Response) ParseTplContent(content string, params ...gview.Params) (stri
}
// buildInVars merges build-in variables into <params> and returns the new template variables.
+// TODO performance improving.
func (r *Response) buildInVars(params ...map[string]interface{}) map[string]interface{} {
- m := gutil.MapMergeCopy(params...)
+ m := gutil.MapMergeCopy(r.Request.viewParams)
+ if len(params) > 0 {
+ gutil.MapMerge(m, params[0])
+ }
// Retrieve custom template variables from request object.
- gutil.MapMerge(m, r.Request.viewParams, map[string]interface{}{
+ gutil.MapMerge(m, map[string]interface{}{
"Form": r.Request.GetFormMap(),
"Query": r.Request.GetQueryMap(),
- "Request": r.Request.GetMap(),
"Cookie": r.Request.Cookie.Map(),
"Session": r.Request.Session.Map(),
})
