当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 0

Simbory/mego
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
viewEngine.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
simbory 提交于 2020-07-03 15:39 . 弃用net/http,采用fasthttp
package mego
import (
"html/template"
)
// ViewEngine the mego view engine struct
type ViewEngine struct {
engine *tplEngine
reader TplReader
tplFuncMap template.FuncMap
compression bool
}
// render render the view 'viewName' with 'data' and get the view result
func (e *ViewEngine) render(viewName string, data interface{}) Result {
if e.reader == nil {
return nil
}
if len(viewName) == 0 {
return nil
}
return &viewResult{
viewName: viewName,
data: data,
engine: e.engine,
compression: e.compression,
}
}
// Extend extend the view helper functions with 'name' and 'tplFuncMap'
func (e *ViewEngine) Extend(name string, viewFunc interface{}) {
notEmpty("name", name)
notNil("tplFuncMap", viewFunc)
e.engine.AddFunc(name, viewFunc)
}
// newViewEngine create a new view engine in ViewDir with file extension '.gohtml'
func newViewEngine(ioutil TplReader) *ViewEngine {
ve, err := newTplEngine(ioutil, ".gohtml")
panicErr(err)
return &ViewEngine{
engine: ve,
reader: ioutil,
tplFuncMap: make(template.FuncMap),
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/simbory/mego.git
git@gitee.com:simbory/mego.git
simbory
mego
mego
master

搜索帮助