aboutsummaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/context.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index bed4760322..2076ef82ab 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -48,10 +48,11 @@ type Render interface {
// Context represents context of a request.
type Context struct {
- Resp ResponseWriter
- Req *http.Request
- Data map[string]interface{}
- Render Render
+ Resp ResponseWriter
+ Req *http.Request
+ Data map[string]interface{} // data used by MVC templates
+ PageData map[string]interface{} // data used by JavaScript modules in one page
+ Render Render
translation.Locale
Cache cache.Cache
csrf CSRF
@@ -646,6 +647,9 @@ func Contexter() func(next http.Handler) http.Handler {
"Link": link,
},
}
+ // PageData is passed by reference, and it will be rendered to `window.config.PageData` in `head.tmpl` for JavaScript modules
+ ctx.PageData = map[string]interface{}{}
+ ctx.Data["PageData"] = ctx.PageData
ctx.Req = WithContext(req, &ctx)
ctx.csrf = Csrfer(csrfOpts, &ctx)