echotemplate

package module
v0.0.0-...-c3d2057 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = TemplateConfig{
	Root:         "views",
	Extension:    ".html",
	Master:       "layouts/master",
	Partials:     []string{},
	Funcs:        make(template.FuncMap),
	DisableCache: false,
	Delims:       Delims{Left: "{{", Right: "}}"},
}

DefaultConfig defines the default settings for templating

Functions

func Middleware

func Middleware(e *TemplateEngine) echo.MiddlewareFunc

func NewMiddleware

func NewMiddleware(config TemplateConfig) echo.MiddlewareFunc

New gin middleware for func `gintemplate.Render()`

func Render

func Render(ctx echo.Context, code int, name string, data interface{}) error

You should use helper func `Middleware()` to set the supplied TemplateEngine and make `Render()` work validly.

Types

type Delims

type Delims struct {
	Left  string
	Right string
}

type FileHandler

type FileHandler func(config TemplateConfig, tplFile string) (content string, err error)

func DefaultFileHandler

func DefaultFileHandler() FileHandler

func FileHandlerEmbed

func FileHandlerEmbed(fs embed.FS) FileHandler

func FileHandlerRice

func FileHandlerRice(viewsRootBox *rice.Box) FileHandler

type TemplateConfig

type TemplateConfig struct {
	Root         string           //view root
	Extension    string           //template extension
	Master       string           //template master
	Partials     []string         //template partial, such as head, foot
	Funcs        template.FuncMap //template functions
	DisableCache bool             //disable cache, debug mode
	Delims       Delims           //delimeters
}

type TemplateEngine

type TemplateEngine struct {
	// contains filtered or unexported fields
}

func Default

func Default() *TemplateEngine

func New

func New(config TemplateConfig) *TemplateEngine

func NewEmbed

func NewEmbed(fs embed.FS) *TemplateEngine

func NewRice

func NewRice(viewsRootBox *rice.Box) *TemplateEngine

func NewWithConfigEmbed

func NewWithConfigEmbed(fs embed.FS, config TemplateConfig) *TemplateEngine

func NewWithConfigRice

func NewWithConfigRice(viewsRootBox *rice.Box, config TemplateConfig) *TemplateEngine

func (*TemplateEngine) Render

func (e *TemplateEngine) Render(w io.Writer, name string, data interface{}, c echo.Context) error

func (*TemplateEngine) SetFileHandler

func (e *TemplateEngine) SetFileHandler(handle FileHandler)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL