gview

package
v0.0.0-...-3631402 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

视图管理.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(content string) template.HTML

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

func ParseContent

func ParseContent(content string, params map[string]interface{}) ([]byte, error)

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

Types

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) BindFunc

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

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

func (*View) Parse

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

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

func (*View) ParseContent

func (view *View) ParseContent(content string, params 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