去掉gview.HTML

This commit is contained in:
John
2018-10-29 23:22:01 +08:00
parent ddf979e65b
commit cb2d40ed1a
11 changed files with 28 additions and 31 deletions

View File

@ -230,7 +230,7 @@ func Redis(name...string) *gredis.Redis {
}
// 模板内置方法config
func funcConfig(pattern string, file...string) gview.HTML {
return gview.HTML(Config().GetString(pattern, file...))
func funcConfig(pattern string, file...string) string {
return Config().GetString(pattern, file...)
}

View File

@ -83,16 +83,16 @@ func (r *Response) buildInFuncs(funcmap map[string]interface{}) map[string]inter
}
// 模板内置函数: get
func (r *Response) funcGet(key string, def...string) gview.HTML {
return gview.HTML(r.request.GetQueryString(key, def...))
func (r *Response) funcGet(key string, def...string) string {
return r.request.GetQueryString(key, def...)
}
// 模板内置函数: post
func (r *Response) funcPost(key string, def...string) gview.HTML {
return gview.HTML(r.request.GetPostString(key, def...))
func (r *Response) funcPost(key string, def...string) string {
return r.request.GetPostString(key, def...)
}
// 模板内置函数: request
func (r *Response) funcRequest(key string, def...string) gview.HTML {
return gview.HTML(r.request.Get(key, def...))
func (r *Response) funcRequest(key string, def...string) string {
return r.request.Get(key, def...)
}

View File

@ -33,9 +33,6 @@ type View struct {
delimiters []string // 模板变量分隔符号
}
// 输出到模板页面时保留HTML标签原意不做自动escape处理
type HTML = string
// 模板变量
type Params = map[string]interface{}

View File

@ -11,7 +11,7 @@ func main() {
{{"<div>测试</div>"|html}}
{{"&lt;div&gt;测试&lt;/div&gt;"|htmldecode}}
{{"https://gfer.me"|url}}
{{"https://gfer.me"|urldecode}}
{{"https%3A%2F%2Fgfer.me"|urldecode}}
{{1540822968 | date "Y-m-d"}}
{{"1540822968" | date "Y-m-d H:i:s"}}
{{compare "A" "B"}}

View File

@ -27,10 +27,10 @@ func main() {
</body>
</html>
`, g.Map{
"page1" : gview.HTML(page.GetContent(1)),
"page2" : gview.HTML(page.GetContent(2)),
"page3" : gview.HTML(page.GetContent(3)),
"page4" : gview.HTML(page.GetContent(4)),
"page1" : page.GetContent(1),
"page2" : page.GetContent(2),
"page3" : page.GetContent(3),
"page4" : page.GetContent(4),
})
r.Response.Write(buffer)
})

View File

@ -33,7 +33,7 @@ func main() {
</body>
</html>
`, g.Map{
"page" : gview.HTML(page.GetContent(1)),
"page" : page.GetContent(1),
})
r.Response.Write(buffer)
})

View File

@ -38,7 +38,7 @@ func main() {
</body>
</html>
`, g.Map{
"page" : gview.HTML(content),
"page" : content,
})
r.Response.Write(buffer)
})

View File

@ -38,7 +38,7 @@ func main() {
</body>
</html>
`, g.Map{
"page" : gview.HTML(pageContent(page)),
"page" : pageContent(page),
})
r.Response.Write(buffer)
})

View File

@ -27,10 +27,10 @@ func main() {
</body>
</html>
`, g.Map{
"page1" : gview.HTML(page.GetContent(1)),
"page2" : gview.HTML(page.GetContent(2)),
"page3" : gview.HTML(page.GetContent(3)),
"page4" : gview.HTML(page.GetContent(4)),
"page1" : page.GetContent(1),
"page2" : page.GetContent(2),
"page3" : page.GetContent(3),
"page4" : page.GetContent(4),
})
r.Response.Write(buffer)
})

View File

@ -27,10 +27,10 @@ func main() {
</body>
</html>
`, g.Map{
"page1" : gview.HTML(page.GetContent(1)),
"page2" : gview.HTML(page.GetContent(2)),
"page3" : gview.HTML(page.GetContent(3)),
"page4" : gview.HTML(page.GetContent(4)),
"page1" : page.GetContent(1),
"page2" : page.GetContent(2),
"page3" : page.GetContent(3),
"page4" : page.GetContent(4),
})
r.Response.Write(buffer)
})

View File

@ -28,10 +28,10 @@ func main() {
</body>
</html>
`, g.Map{
"page1" : gview.HTML(page.GetContent(1)),
"page2" : gview.HTML(page.GetContent(2)),
"page3" : gview.HTML(page.GetContent(3)),
"page4" : gview.HTML(page.GetContent(4)),
"page1" : page.GetContent(1),
"page2" : page.GetContent(2),
"page3" : page.GetContent(3),
"page4" : page.GetContent(4),
})
r.Response.Write(buffer)
})