1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-25 12:55:57 +00:00

Ability to register a view engine per group of routes or for the current a chain of handlers

Example at: https://github.com/kataras/iris/tree/master/_examples/view/context-view-engine
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-05 19:34:55 +03:00
parent b363492cca
commit 5d480dc801
22 changed files with 282 additions and 66 deletions

View File

@@ -5,6 +5,18 @@ import (
"io"
"path/filepath"
"strings"
"github.com/kataras/iris/v12/context"
)
type (
// Engine is the interface for a compatible Iris view engine.
// It's an alias of context.ViewEngine.
Engine = context.ViewEngine
// EngineFuncer is the interface for a compatible Iris view engine
// which accepts builtin framework functions such as url, urlpath and tr.
// It's an alias of context.ViewEngineFuncer.
EngineFuncer = context.ViewEngineFuncer
)
// View is responsible to
@@ -73,3 +85,19 @@ func (v *View) Load() error {
}
return nil
}
// NoLayout disables the configuration's layout for a specific execution.
const NoLayout = "iris.nolayout"
// returns empty if it's no layout or empty layout and empty configuration's layout.
func getLayout(layout string, globalLayout string) string {
if layout == NoLayout {
return ""
}
if layout == "" && globalLayout != "" {
return globalLayout
}
return layout
}