echo_template

package
v0.0.0-...-3e1c22f Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

* Copyright (c) 2019. Pandranki Global Private Limited

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: "}}"},
}

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

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)

Jump to

Keyboard shortcuts

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