LVTemplate

package
v0.0.0-...-6aeb21f Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2015 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

leafveingo web 模板操作模块

leafveingo web 模板使用函数模块

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Template

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

leafveingo 内置模板结构,用于私有的实现

func NewTemplate

func NewTemplate() *Template

获取模板对象

func (*Template) AddCacheTemplate

func (t *Template) AddCacheTemplate(tplName, src string) error

*

  • add cache template *
  • @param name unique name
  • @param src template content, if empty by name lookup cache template

func (*Template) BaseDir

func (l *Template) BaseDir() string

*

  • get template base path

func (*Template) DelAllFunc

func (l *Template) DelAllFunc()

*

  • delete all template func

func (*Template) DelFunc

func (l *Template) DelFunc(key string)

*

  • delete template func *
  • @param key

func (*Template) Execute

func (l *Template) Execute(wr io.Writer, value TemplateValue) error

*

  • execute template * *
  • @param wr
  • @param value
  • @return error

func (*Template) Get

func (l *Template) Get(tplPath string) *template.Template

*

  • get template by relateve path *
  • @param tplPath template relative path

func (*Template) IsCache

func (l *Template) IsCache() bool

*

  • template cache

func (*Template) IsCompactHTML

func (l *Template) IsCompactHTML() bool

*

  • template format compact

func (*Template) IsDevel

func (l *Template) IsDevel() bool

*

  • is developer model

func (*Template) Parse

func (l *Template) Parse(tplPath string) (tmpl *template.Template, err error)

*

  • pares template by relative path *
  • @param tplPath
  • @return *template.Template
  • @return error

func (*Template) ParseString

func (l *Template) ParseString(name, src string) (tmpl *template.Template, err error)

*

  • parse template string, not template path *
  • @param name unique name
  • @param src template content, if empty by name lookup cache template
  • @return *template.Template
  • @return error

func (*Template) SetBaseDir

func (l *Template) SetBaseDir(path string)

*

  • set template base directory path
  • 设置模板查询主目录,默认"".
  • 主目录空的话就会按照编译文件所在目录开始查询模板 *
  • @param path full path

func (*Template) SetCache

func (l *Template) SetCache(cache bool)

*

  • set template is cache
  • default false *
  • @param cache

func (*Template) SetCompactHTML

func (l *Template) SetCompactHTML(compact bool)

*

  • set template content html format compact
  • default true

func (*Template) SetDelims

func (t *Template) SetDelims(left, right string)

*

  • set the action delimiters left default {{ }} *
  • @param left
  • @param right

func (*Template) SetDevel

func (l *Template) SetDevel(isDevel bool)

*

  • set template developer model

func (*Template) SetFunc

func (l *Template) SetFunc(key string, methodFunc interface{})

*

  • set template func *
  • default func see lv_tempate_func.go
  • "LVEmbedTempate" LVTemplate.EmbedTempate //嵌入模板函数 *
  • @param key
  • @param methodFunc

func (*Template) TemplatePathAtName

func (l *Template) TemplatePathAtName(tplName string) string

*

  • template name join full path *
  • @param tplName
  • @return not find is ""

type TemplateValue

type TemplateValue struct {
	TplName     string      //	template name precedence handle
	TplPath     string      //	template relative path
	ContentType string      //	response header Content-Type
	Data        interface{} //	bind data
}

模板数据,用于封装使用模板的数据传递

func NewTemplateValue

func NewTemplateValue(tplPath string, data interface{}) TemplateValue

new template value @tplPth 相对路径 @data 模板数据

func NewTemplateValueByName

func NewTemplateValueByName(tplName string, data interface{}) TemplateValue

*

*

Jump to

Keyboard shortcuts

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