Documentation
¶
Index ¶
- type Engine
- func (e *Engine) AddFunc(name string, fn interface{}) IEngineCore
- func (e *Engine) AddFuncMap(m map[string]interface{}) IEngineCore
- func (e *Engine) Debug(enabled bool) IEngineCore
- func (e *Engine) Delims(left, right string) IEngineCore
- func (e *Engine) FuncMap() map[string]interface{}
- func (e *Engine) Layout(key string) IEngineCore
- func (e *Engine) PreRenderCheck() bool
- func (e *Engine) Reload(enabled bool) IEngineCore
- type IEngine
- type IEngineCore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
IEngineCore
// delimiters
Left string
Right string
// views folder
Directory string
// http.FileSystem supports embedded files
FileSystem http.FileSystem
// views extension
Extension string
// layout variable name that incapsulates the template
LayoutName string
// determines if the engine parsed all templates
Loaded bool
// reload on each render
ShouldReload bool
// debug prints the parsed templates
Verbose bool
// lock for funcmap and templates
Mutex sync.RWMutex
// template funcmap
Funcmap map[string]interface{}
}
Engine engine struct
func (*Engine) AddFunc ¶
func (e *Engine) AddFunc(name string, fn interface{}) IEngineCore
AddFunc adds the function to the template's function map. It is legal to overwrite elements of the default actions
func (*Engine) AddFuncMap ¶
func (e *Engine) AddFuncMap(m map[string]interface{}) IEngineCore
AddFuncMap adds the functions from a map to the template's function map. It is legal to overwrite elements of the default actions
func (*Engine) Debug ¶
func (e *Engine) Debug(enabled bool) IEngineCore
Debug will print the parsed templates when Load is triggered.
func (*Engine) Delims ¶
func (e *Engine) Delims(left, right string) IEngineCore
Delims sets the action delimiters to the specified strings, to be used in templates. An empty delimiter stands for the corresponding default: "{{" and "}}".
func (*Engine) Layout ¶
func (e *Engine) Layout(key string) IEngineCore
Layout defines the variable name that will incapsulate the template
func (*Engine) PreRenderCheck ¶ added in v1.8.3
Check if the engine should reload the templates before rendering Explicit Mute Unlock vs defer offers better performance
func (*Engine) Reload ¶
func (e *Engine) Reload(enabled bool) IEngineCore
Reload if set to true the templates are reloading on each render, use it when you're in development and you don't want to restart the application when you edit a template file.
type IEngine ¶
type IEngine interface {
IEngineCore
Load() error
Render(out io.Writer, template string, binding interface{}, layout ...string) error
}
IEngine interface, to be implemented for any templating engine added to the repository
type IEngineCore ¶
type IEngineCore interface {
AddFunc(name string, fn interface{}) IEngineCore
AddFuncMap(m map[string]interface{}) IEngineCore
Debug(enabled bool) IEngineCore
Delims(left, right string) IEngineCore
FuncMap() map[string]interface{}
Layout(key string) IEngineCore
Reload(enabled bool) IEngineCore
PreRenderCheck() bool
}
IEngineCore interface

