Iris supports 7 template engines out-of-the-box, developers can still use any external golang template engine, as Context.ResponseWriter() is an io.Writer.
All template engines share a common API i.e. Parse using embedded assets, Layouts and Party-specific layout, Template Funcs, Partial Render and more.
#
Name
Parser
1
HTML
2
Blocks
3
Django
4
Pug
5
Handlebars
6
Jet
7
Ace
.
A view engine can be registered per-Party. To register a view engine use the Application/Party.RegisterView(ViewEngine) method as shown below.
Load all templates from the "./views" folder where extension is ".html" and parse them using the standard html/template package.
Iris allows unlimited number of registered view engines per Application. Besides that, you can register a view engine per Party or through middleware too!.
// Register a view engine per group of routes.
adminGroup := app.Party("/admin")
adminGroup.RegisterView(iris.Blocks("./views/admin", ".html"))
// Register a view engine on-fly for the current chain of handlers.
views := iris.Blocks("./views/on-fly", ".html")
views.Load()
app.Get("/", setViews(views), onFly)
To use embedded templates and not depend on local file system use the external tool and pass its Asset and AssetNames functions to the Binary method of the preferred view engine.