gview

package
v1.0.898 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

视图管理.

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 HTML

type HTML = template.HTML

输出到模板页面时保留HTML标签原意,不做自动escape处理

type Params

type Params = map[string]interface{}

模板变量

type View

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

视图对象

func Get

func Get(path string) *View

获取或者创建一个视图对象

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

设置模板目录绝对路径

Jump to

Keyboard shortcuts

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