views

package
v0.0.0-...-d30b894 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ViewEngine

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

func NewEngine

func NewEngine(rootDir, ext string) (*ViewEngine, error)

NewEngine create a new view engine. rootDir: the root dir of the view files; ext: the view file extension(starts with "."), and the default file extension is '.gohtml';

func (*ViewEngine) AddFunc

func (engine *ViewEngine) AddFunc(name string, viewFunc interface{})

AddFunc add new view func to the view files

func (*ViewEngine) Clear

func (engine *ViewEngine) Clear()

Clear clear all the cache in the view engine. and re-compile the view files into memory at next call 'Render' or 'RenderStr'

func (*ViewEngine) Render

func (engine *ViewEngine) Render(writer io.Writer, viewPath string, viewData interface{}) error

Render render the view file with given data and then write the result to an io writer. viewPath: the relative view file path that will be rendered. viewData: the view data writer: the given io writer

func (*ViewEngine) RenderStr

func (engine *ViewEngine) RenderStr(viewPath string, viewData interface{}) (string, error)

RenderStr render the view file with given data then get the result. viewPath: the relative view file path that will be rendered viewData: the view data

Jump to

Keyboard shortcuts

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