Iris offers support for 6 template parsers out of the box through its universal View Engine. Of course developers can still use various go template parsers as the Context.ResponseWriter() completes the http.ResponseWriter and io.Writer.

Iris puts some common rules and features that their original parsers don't support by default. For example we have support for yield, render, render_r, current, urlpath template funcs and Layouts and binding across middlewares and embedded template files for all Engines.

To use unique features of a template engine you have to learn the characteristics and the syntax by reading its documentation (click the links below). Choose what fits your app's needs the most.

Let's see the list of the built-in view engines:



Underline Template Parser

std template/html


html/template package



flosch/pongo2 package



Joker/jade package



aymerick/raymond package



eknkc/amber package



CloudyKit/jet package

One or more view engines can be registered in the same Application. To register a view engine use the RegisterView(ViewEngine) method.

Load all templates from the "./views" folder where extension is ".html" and parse them using the standard html/template package.

// [app := iris.New...]
tmpl := iris.HTML("./views", ".html")

To render or execute a view use the Context.View method inside the main route's handler.


To bind Go values with key-value pattern inside a view through middleware or main handler use the Context.ViewData method before the Context.View one.

Bind: {{.message}} with "Hello world!".

ctx.ViewData("message", "Hello world!")

To bind a Go model to a view you have two options:

  • ctx.ViewData("user", User{}) - variable binding as {{.user.Name}} for example

  • ctx.View("user-page.html", User{}) - root binding as {{.Name}} for example.

To add a template function use the AddFunc method of the preferred view engine.

// func name, input arguments, render value
tmpl.AddFunc("greet", func(s string) string {
return "Greetings " + s + "!"

To reload on local file changes call the view engine's Reload method.


To use embedded templates and not depend on local file system use the go-bindata external tool and pass its Asset and AssetNames functions to the Binary method of the preferred view engine.

tmpl.Binary(Asset, AssetNames)

Example Code:

Please read the comments too.

// file: main.go
package main
import ""
func main() {
app := iris.New()
// Parse all templates from the "./views" folder
// where extension is ".html" and parse them
// using the standard `html/template` package.
tmpl := iris.HTML("./views", ".html")
// Enable re-build on local template files changes.
// Default template funcs are:
// - {{ urlpath "myNamedRoute" "pathParameter_ifNeeded" }}
// - {{ render "header.html" }}
// and partial relative path to current page:
// - {{ render_r "header.html" }}
// - {{ yield }}
// - {{ current }}
// Register a custom template func:
tmpl.AddFunc("greet", func(s string) string {
return "Greetings " + s + "!"
// Register the view engine to the views,
// this will load the templates.
// Method: GET
// Resource: http://localhost:8080
app.Get("/", func(ctx iris.Context) {
// Bind: {{.message}} with "Hello world!"
ctx.ViewData("message", "Hello world!")
// Render template file: ./views/hi.html
<!-- file: ./views/hi.html -->
<title>Hi Page</title>
<strong>{{greet "to you"}}</strong>

Open a browser tab at http://localhost:8080.

The rendered result will look like this:

<title>Hi Page</title>
<h1>Hello world!</h1>
<strong>Greetings to you!</strong>