Back to godoc.org
github.com/xf005/echo-template

Package echotemplate

v0.0.0-...-9637776
Latest Go to latest

The highest tagged major version is .

Published: Nov 10, 2019 | License: MIT | Module: github.com/xf005/echo-template

Overview

Golang template for echo framework, Use golang html/template syntax, Easy and simple to use for echo framework, See https://github.com/foolin/echo-template for more information.

Index

Variables

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