Documentation
¶
Overview ¶
*
模板扩展
@author swh <swh@admpub.com>
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func Del(key string)
- func FixDirSeparator(dir string) string
- func Reg(key string, val func(string) TemplateEx)
- type CcRel
- type TemplateEx
- type TemplateMgr
- func (self *TemplateMgr) AllowCached(name string) bool
- func (self *TemplateMgr) CacheAll(rootDir string) error
- func (self *TemplateMgr) CacheDelete(tmpl string)
- func (self *TemplateMgr) CacheTemplate(tmpl string, content []byte)
- func (self *TemplateMgr) ClearCache()
- func (self *TemplateMgr) Close()
- func (self *TemplateMgr) CloseMoniter()
- func (self *TemplateMgr) GetTemplate(tmpl string) ([]byte, error)
- func (self *TemplateMgr) Init(logger *log.Logger, rootDir string, reload bool, allows ...string) error
- func (self *TemplateMgr) Moniter(rootDir string) error
- func (self *TemplateMgr) OnChange(name, typ, event string)
Constants ¶
This section is empty.
Variables ¶
View Source
var Debug = false
Functions ¶
func FixDirSeparator ¶
func Reg ¶
func Reg(key string, val func(string) TemplateEx)
Types ¶
type TemplateEx ¶
type TemplateEx interface {
Init(...bool)
SetFuncMapFn(func() map[string]interface{})
Render(io.Writer, string, interface{}, map[string]interface{}) error
Fetch(string, interface{}, map[string]interface{}) string
RawContent(string) ([]byte, error)
MonitorEvent(func(string))
ClearCache()
Close()
}
func Create ¶
func Create(key string, tmplDir string) TemplateEx
func New ¶
func New(templateDir string) TemplateEx
type TemplateMgr ¶
type TemplateMgr struct {
Caches map[string][]byte
Mutex *sync.Mutex
RootDir string
NewRoorDir string
Ignores map[string]bool
CachedAllows map[string]bool
IsReload bool
Logger *log.Logger
Preprocessor func([]byte) []byte
TimerCallback func() bool
OnChangeCallback func(string, string, string) //参数为:目标名称,类型(file/dir),事件名(create/delete/modify/rename)
// contains filtered or unexported fields
}
func (*TemplateMgr) AllowCached ¶
func (self *TemplateMgr) AllowCached(name string) bool
func (*TemplateMgr) CacheAll ¶
func (self *TemplateMgr) CacheAll(rootDir string) error
func (*TemplateMgr) CacheDelete ¶
func (self *TemplateMgr) CacheDelete(tmpl string)
func (*TemplateMgr) CacheTemplate ¶
func (self *TemplateMgr) CacheTemplate(tmpl string, content []byte)
func (*TemplateMgr) ClearCache ¶
func (self *TemplateMgr) ClearCache()
func (*TemplateMgr) Close ¶
func (self *TemplateMgr) Close()
func (*TemplateMgr) CloseMoniter ¶
func (self *TemplateMgr) CloseMoniter()
func (*TemplateMgr) GetTemplate ¶
func (self *TemplateMgr) GetTemplate(tmpl string) ([]byte, error)
func (*TemplateMgr) Moniter ¶
func (self *TemplateMgr) Moniter(rootDir string) error
func (*TemplateMgr) OnChange ¶
func (self *TemplateMgr) OnChange(name, typ, event string)
Click to show internal directories.
Click to hide internal directories.