func (this *HTMLHeadMiddleWare) View(ctxt *web.Context, vw mvc.View) { var head *HTMLHead if dview, ok := vw.(mvc.DataView); ok && ctxt.MapResourceValue("htmlhead", &head) == nil && head != nil { dview.SetData("Htmlhead_Title", head.Title()) dview.SetData("Htmlhead_Css", head.Css()) dview.SetData("Htmlhead_Scripts", head.Scripts()) } }
func (this CsrfMiddleWare) View(ctxt *web.Context, vw mvc.View) { var csrftoken CsrfTokenGetter if ctxt.MapResourceValue("csrftoken", &csrftoken) == nil && csrftoken.context != nil { if dview, ok := vw.(mvc.DataView); ok { dview.SetData("Csrftoken_Value", csrftoken.Value()) dview.SetData("Csrftoken_Name", csrftoken.Name()) dview.SetData("Csrftoken_Formtoken", csrftoken.FormToken()) } if fview, ok := vw.(mvc.TmplView); ok { fview.SetViewFunc("URLWToken", func(path string) string { return csrftoken.URLWToken(path) }) fview.SetViewFunc("URLWTokenQ", csrftoken.URLWToken) } } }