Documentation ¶
Index ¶
- Variables
- func AddFuncMap(name string, f interface{}) error
- func Compare(a, b interface{}) (equal bool)
- func CompareNot(a, b interface{}) (equal bool)
- func Date(t time.Time, format string) string
- func DateFormat(t time.Time, layout string) (datestring string)
- func DateParse(dateString, format string) (time.Time, error)
- func Empty(a interface{}) bool
- func HTML2str(html string) string
- func Htmlquote(text string) string
- func Htmlunquote(text string) string
- func Init(_viewPath, _templateExt, _langRoot, _langExt string, _debug bool)
- func UnHTML(x string) interface{}
- type Template
- func (t *Template) AssociatesTemplate(paths ...string) (r []*template.Template, errPath string, err error)
- func (t *Template) AssociatesTemplateAuto()
- func (t *Template) Execute(wr io.Writer, data interface{}, cacheTime int64) (err error)
- func (t *Template) GetLang(langName string, extra ...string) (langData map[string]string)
- func (t *Template) UseCache(wr io.Writer) (successful bool)
- func (t *Template) UseCacheAlways(wr io.Writer) (successful bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var Errs = struct { ErrNotFound error // 未找到错误 }{ errors.New("file not found"), }
Errs 预定义错误
Functions ¶
func AddFuncMap ¶
AddFuncMap 添加模板函数,需要在Init模板初始化之前添加才能生效
func Compare ¶
func Compare(a, b interface{}) (equal bool)
Compare 比较两个对象,如果相同返回 true,否者 false,使用方法 {{compare .A .B}}
func DateFormat ¶
DateFormat 时间的格式化,返回字符串,使用方法 {{dateformat .Time “2006-01-02T15:04:05Z07:00”}}
func Htmlunquote ¶
Htmlunquote html字符反转义,使用方法 {{htmlunquote .unquote}}
Types ¶
type Template ¶
type Template struct { T *template.Template M *sync.RWMutex // contains filtered or unexported fields }
Template Template
func (*Template) AssociatesTemplate ¶
func (t *Template) AssociatesTemplate(paths ...string) (r []*template.Template, errPath string, err error)
AssociatesTemplate 关联模板
func (*Template) AssociatesTemplateAuto ¶
func (t *Template) AssociatesTemplateAuto()
AssociatesTemplateAuto 在相同目录下自动寻找并关联模板
Click to show internal directories.
Click to hide internal directories.