mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 11:57:02 +00:00
Add notes for the new lead maintainer of the open-source iris project and align with @get-ion/ion by @hiveminded
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
This commit is contained in:
47
_examples/view/overview/main.go
Normal file
47
_examples/view/overview/main.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
)
|
||||
|
||||
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 context.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(...)
|
||||
*/
|
||||
Reference in New Issue
Block a user