| 阅读 | 共 158 字,阅读约
基本使用
源码分析
1type Template struct {
2 name string // template的名称
3 *parse.Tree // 解析树
4 *common
5 leftDelim string // 左边分隔符,默认为{{}}
6 rightDelim string // 左边分隔符,默认为{{}}
7}
8
9type common struct {
10 // 所有的template共享同一个common
11 tmpl map[string]*Template // Map from name to defined templates.
12 option option
13 // We use two maps, one for parsing and one for execution.
14 // This separation makes the API cleaner since it doesn't
15 // expose reflection to the client.
16 muFuncs sync.RWMutex // protects parseFuncs and execFuncs
17 parseFuncs FuncMap
18 execFuncs map[string]reflect.Value
19}