gview

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package gview implements a template engine based on text/template.

模板引擎.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseContent

func ParseContent(content string, params Params) ([]byte, error)

直接解析模板内容,返回解析后的内容

Types

type FuncMap

type FuncMap = map[string]interface{}

函数映射表

type Params

type Params = map[string]interface{}

模板变量

type View

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

视图对象

func New

func New(path ...string) *View

生成一个视图对象

func (*View) AddPath

func (view *View) AddPath(path string) error

添加模板目录搜索路径

func (*View) Assign

func (view *View) Assign(key string, value interface{})

绑定模板变量,即调用之后每个线程都会生效,因此有并发安全控制

func (*View) Assigns

func (view *View) Assigns(data Params)

批量绑定模板变量,即调用之后每个线程都会生效,因此有并发安全控制

func (*View) BindFunc

func (view *View) BindFunc(name string, function interface{})

绑定自定义函数,该函数是全局有效,即调用之后每个线程都会生效,因此有并发安全控制

func (*View) Parse

func (view *View) Parse(file string, params Params, funcmap ...map[string]interface{}) ([]byte, error)

解析模板,返回解析后的内容

func (*View) ParseContent

func (view *View) ParseContent(content string, params Params, funcmap ...map[string]interface{}) ([]byte, error)

直接解析模板内容,返回解析后的内容

func (*View) SetDelimiters

func (view *View) SetDelimiters(left, right string)

设置模板变量解析分隔符号

func (*View) SetPath

func (view *View) SetPath(path string) error

设置模板目录绝对路径

Directories

Path Synopsis
internal
text
from golang-1.11.2 1.
from golang-1.11.2 1.
text/template
Package template implements data-driven templates for generating textual output.
Package template implements data-driven templates for generating textual output.
text/template/parse
Package parse builds parse trees for templates as defined by text/template and html/template.
Package parse builds parse trees for templates as defined by text/template and html/template.

Jump to

Keyboard shortcuts

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