mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
improve session variable map in template parsing
This commit is contained in:
@ -82,17 +82,18 @@ func (r *Response) buildInVars(params ...map[string]interface{}) map[string]inte
|
||||
gutil.MapMerge(m, params[0])
|
||||
}
|
||||
// Retrieve custom template variables from request object.
|
||||
sessionMap := gconv.MapDeep(r.Request.Session.Map())
|
||||
gutil.MapMerge(m, map[string]interface{}{
|
||||
"Form": r.Request.GetFormMap(),
|
||||
"Query": r.Request.GetQueryMap(),
|
||||
"Request": r.Request.GetMap(),
|
||||
"Cookie": r.Request.Cookie.Map(),
|
||||
"Session": gconv.MapDeep(r.Request.Session.Map()),
|
||||
"Session": sessionMap,
|
||||
})
|
||||
// Note that it should assign no Config variable to template
|
||||
// if there's no configuration file.
|
||||
if c := gcfg.Instance(); c.Available() {
|
||||
m["Config"] = c.GetMap(".")
|
||||
m["Config"] = c.Map()
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user