Back to

Package echotemplate

Latest Go to latest

The highest tagged major version is .

Published: Nov 10, 2019 | License: MIT | Module:


Golang template for echo framework, Use golang html/template syntax, Easy and simple to use for echo framework, See for more information.



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

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.

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

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 (*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)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier