1 Star 0 Fork 0

hh / iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"github.com/kataras/iris"
)
func main() {
app := iris.New()
// - standard html | iris.HTML(...)
// - django | iris.Django(...)
// - pug(jade) | iris.Pug(...)
// - handlebars | iris.Handlebars(...)
// - amber | iris.Amber(...)
// with default template funcs:
//
// - {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
// - {{ render "header.html" }}
// - {{ render_r "header.html" }} // partial relative path to current page
// - {{ yield }}
// - {{ current }}
app.RegisterView(iris.HTML("./templates", ".html"))
app.Get("/", func(ctx iris.Context) {
ctx.ViewData("Name", "iris") // the .Name inside the ./templates/hi.html
ctx.Gzip(true) // enable gzip for big files
ctx.View("hi.html") // render the template with the file name relative to the './templates'
})
// http://localhost:8080/
app.Run(iris.Addr(":8080"))
}
/*
Note:
In case you're wondering, the code behind the view engines derives from the "github.com/kataras/iris/view" package,
access to the engines' variables can be granded by "github.com/kataras/iris" package too.
iris.HTML(...) is a shortcut of view.HTML(...)
iris.Django(...) >> >> view.Django(...)
iris.Pug(...) >> >> view.Pug(...)
iris.Handlebars(...) >> >> view.Handlebars(...)
iris.Amber(...) >> >> view.Amber(...)
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/iris.git
git@gitee.com:w1229748769/iris.git
w1229748769
iris
iris
v8.4.4

搜索帮助

344bd9b3 5694891 D2dac590 5694891