(filename string, optionalViewModel ...interface{})
| 3960 | } |
| 3961 | |
| 3962 | func (ctx *Context) renderView(filename string, optionalViewModel ...interface{}) error { |
| 3963 | cfg := ctx.app.ConfigurationReadOnly() |
| 3964 | layout := ctx.values.GetString(cfg.GetViewLayoutContextKey()) |
| 3965 | |
| 3966 | var bindingData interface{} |
| 3967 | if len(optionalViewModel) > 0 /* Don't do it: can break a lot of servers: && optionalViewModel[0] != nil */ { |
| 3968 | // a nil can override the existing data or model sent by `ViewData`. |
| 3969 | bindingData = optionalViewModel[0] |
| 3970 | } else { |
| 3971 | bindingData = ctx.values.Get(cfg.GetViewDataContextKey()) |
| 3972 | } |
| 3973 | |
| 3974 | if key := cfg.GetViewEngineContextKey(); key != "" { |
| 3975 | if engineV := ctx.values.Get(key); engineV != nil { |
| 3976 | if engine, ok := engineV.(ViewEngine); ok { |
| 3977 | return engine.ExecuteWriter(ctx, filename, layout, bindingData) |
| 3978 | } |
| 3979 | } |
| 3980 | } |
| 3981 | |
| 3982 | return ctx.app.View(ctx, filename, layout, bindingData) |
| 3983 | } |
| 3984 | |
| 3985 | const ( |
| 3986 | // ContentBinaryHeaderValue header value for binary data. |
no test coverage detected