FallbackView registers one or more fallback views for a template or a template layout. When View cannot find the given filename to execute then this "provider" is responsible to handle the error or render a different view. Usage: FallbackView(iris.FallbackView("fallback.html")) FallbackView(iris
(providers ...FallbackViewProvider)
| 3903 | // [...custom logic e.g. ctx.View("fallback", err.Data)] |
| 3904 | // }) |
| 3905 | func (ctx *Context) FallbackView(providers ...FallbackViewProvider) { |
| 3906 | key := ctx.app.ConfigurationReadOnly().GetFallbackViewContextKey() |
| 3907 | if key == "" { |
| 3908 | return |
| 3909 | } |
| 3910 | |
| 3911 | v := ctx.values.Get(key) |
| 3912 | if v == nil { |
| 3913 | ctx.values.Set(key, providers) |
| 3914 | return |
| 3915 | } |
| 3916 | |
| 3917 | // Can register more than one. |
| 3918 | storedProviders, ok := v.([]FallbackViewProvider) |
| 3919 | if !ok { |
| 3920 | return |
| 3921 | } |
| 3922 | |
| 3923 | storedProviders = append(storedProviders, providers...) |
| 3924 | ctx.values.Set(key, storedProviders) |
| 3925 | } |
| 3926 | |
| 3927 | // View renders a template based on the registered view engine(s). |
| 3928 | // First argument accepts the filename, relative to the view engine's Directory and Extension, |
nothing calls this directly
no test coverage detected