MCPcopy Create free account
hub / github.com/kataras/iris / ViewData

Method ViewData

context/context.go:3741–3757  ·  view source on GitHub ↗

ViewData saves one or more key-value pair in order to be passed if and when .View is being called afterwards, in the same request. Useful when need to set or/and change template data from previous hanadlers in the chain. If .View's "binding" argument is not nil and it's not a type of map then these

(key string, value interface{})

Source from the content-addressed store, hash-verified

3739//
3740// Example: https://github.com/kataras/iris/tree/main/_examples/view/context-view-data/
3741func (ctx *Context) ViewData(key string, value interface{}) {
3742 viewDataContextKey := ctx.app.ConfigurationReadOnly().GetViewDataContextKey()
3743 if key == "" {
3744 ctx.values.Set(viewDataContextKey, value)
3745 return
3746 }
3747
3748 v := ctx.values.Get(viewDataContextKey)
3749 if v == nil {
3750 ctx.values.Set(viewDataContextKey, Map{key: value})
3751 return
3752 }
3753
3754 if data, ok := v.(Map); ok {
3755 data[key] = value
3756 }
3757}
3758
3759// GetViewData returns the values registered by `context#ViewData`.
3760// The return value is `map[string]interface{}`, this means that

Callers 15

setSessionViewDataFunction · 0.80
newAppFunction · 0.80
registerFormFunction · 0.80
mainFunction · 0.80
hiFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 4

GetViewDataContextKeyMethod · 0.65
ConfigurationReadOnlyMethod · 0.65
SetMethod · 0.65
GetMethod · 0.65

Tested by 1

BeginRequestMethod · 0.64