mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
076d9121f1
Former-commit-id: 3e00bdfbf1f3998a1744c390c12fd70430ac0320
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package view
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
|
|
// Engine is the interface which all view engines should be implemented in order to be registered inside iris.
|
|
type Engine interface {
|
|
// Load should load the templates from a physical system directory or by an embedded one (assets/go-bindata).
|
|
Load() error
|
|
// ExecuteWriter should execute a template by its filename with an optional layout and bindingData.
|
|
ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
|
|
// Ext should return the final file extension which this view engine is responsible to render.
|
|
Ext() string
|
|
}
|
|
|
|
type namedEngine interface {
|
|
String() string
|
|
}
|
|
|
|
func getEngineName(e Engine) string {
|
|
if n, ok := e.(namedEngine); ok {
|
|
return n.String()
|
|
}
|
|
|
|
return ""
|
|
}
|