templates

package module
Version: v0.0.0-...-4d9aea5 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 16 Imported by: 0

README

go-templates

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplate = errors.New("template can't be nil")
	ErrName     = errors.New("template must have a name")
)
View Source
var (
	FuncMap = types.Map{

		"html": func(v string) template.HTML {
			return template.HTML(v)
		},

		"js": func(v interface{}) template.JS {
			encoded, _ := json.Marshal(v)
			return template.JS(encoded)
		},

		"ToLower": strings.ToLower,
		"ToUpper": strings.ToUpper,

		"Int":    convert.Int,
		"String": convert.String,
	}
)

Functions

func Gin

func Gin(cfg Config)

Gin creates a new renderer for gin-gonic framework.

Types

type Config

type Config struct {
	Layout    string
	Extension string
	Debug     bool // Debug mode will enable files watcher.
	Directory string
	Funcs     types.Map
}

type EchoRenderer

type EchoRenderer interface {
	Render(io.Writer, string, interface{}, echo.Context) error
}

func Echo

func Echo(cfg Config) EchoRenderer

Echo creates a new renderer for echo framework.

type Engine

type Engine interface {
	// Parse(tpl string, v interface{})
	Load(string) *template.Template
}

func Create

func Create(config Config) Engine

Create

type RenderFunc

type RenderFunc func(code int, name string, data interface{}) error

RenderFunc

type Renderer

type Renderer interface {
	Set(key string, v interface{})
	Parse404() error
	Parse500() error
	Parse(code int, name string, values ...map[string]interface{}) error
	AddPostParsing(...func(data types.TSafeMap) error)
}

Renderer

func New

func New(rf RenderFunc) Renderer

New creates a new Renderer with the given callback.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto